curl - Scrape facebook fan page in PHP -
i'm trying scrape facebook fanpage using curl in php give's me blank page. here code.
function curlfunction($source_url){ $ch = curl_init(); $useragent = 'mozilla/5.0 (windows nt 6.1; wow64; rv:15.0) gecko/20100101 firefox/15.0.1'; curl_setopt($ch, curlopt_useragent, $useragent); curl_setopt($ch, curlopt_url, $source_url); curl_setopt($ch, curlopt_header, false); curl_setopt($ch, curlopt_failonerror, true); curl_setopt($ch, curlopt_encoding, "utf-8" ); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch, curlopt_autoreferer, true); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_timeout, 60); $html= curl_exec($ch); curl_close($ch); return $html; } $token = "caacedeose0cbadmek5ullfstj1nzcg8eogazbi6dfkr4gjn9o6ffuyfehkpto94br9i9yp9gmiypunhxrxr1pqu3yny34pziacweamxl4nt9zzbmgdwd6wfh6mal2dlqsjnys9skq5sz7zcvbn7za8lvrzcjrq8o0zd"; $url = "https://graph.facebook.com/starhub/feed?accesstoken=" . $token; $html = curlfunction($url, $info); echo $html;
i use function other websites scrape pages , works fine. , encountered problem, when use https gives me blank page when use http works fine, facebook graph api requiring me use https contents.
pages public , feed can read app access token. try changing access token this:
$token = "app-id|app-secret";
(app id , app secret, pipe in middle)
that´s token never expires, if change id or secret of app.
another solution php sdk:
$result = $facebook->api('/page-id/feed', array('access_token' => 'app-id|app-secret')); var_dump($result['data']);
you might able without access token, if no user authorized should use app access token anyway.
Comments
Post a Comment