What I want is to fetch data using of a public page.
I tried the documentation, but wasn't able to find that information. Then I googled it and found this Can you get a public Facebook page's feed using Graph API without asking a user to allow? question here at stackoverflow and that perfectly explained what I want to do with PHP. I read in the McNab's answer that I need an app at facebook to fetch that data (to retrieve an access token). I created an app and it took me to the basic settings page where it gave me the AppId and the AppSecret. Now as from the McNab answer, I only need AppId and app secret to get the auth_token, I used the following code, but due to some reason I get false
instead of the AuthToken. What am I doing wrong here? I didn't add any further details to the app, is it causing this problem, do I need to add further details to the app or is there anything else causing this?
P.S Also I am trying this on localhost on my PC.
function fetchUrl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$feedData = curl_exec($ch);
curl_close($ch);
return $feedData;
}
$profile_id = "100002138417834";
// App info needed for auth.
$app_id = "--------------";
$app_secret = "-=-=-=-=-=-=-=-=-=-=-=-";
$authToken = fetchUrl("https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id={$app_id}&client_secret={$app_secret}");
var_dump($authToken);
UPDATE:
When I did var_dump(curl_error($ch));
(as suggested in the comments), it gave me this error:
string 'SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' (length=146)