0

I'm trying to use cURL in PHP to retrieve the HTML of https://www.facebook.com/video.php?v=720617444660843, but it's not printing nothing and curl_error is returning nothing.

This is the code I'm using:

$defaults = array(
    CURLOPT_URL => "https://www.facebook.com/video.php?v=720617444660843",
    CURLOPT_HEADER => 0,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_TIMEOUT => 4
);

$ch = curl_init();
curl_setopt_array($ch, $defaults);
if( ! ($result = curl_exec($ch)))
{
    trigger_error(curl_error($ch));
}
curl_close($ch);
echo $result;

1 Answer 1

1

You need to pass user agent

$defaults = array(
CURLOPT_URL => "https://www.facebook.com/video.php?v=720617444660843",
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 4,
CURLOPT_USERAGENT => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.16 (KHTML, like Gecko) \ Chrome/24.0.1304.0 Safari/537.16'
);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.