CycleUP
CycleUP

Reputation: 11

How do I get curl or wget working for graph.facebook.com/..?

When I enter this in my Browser:

https://graph.facebook.com/COMMENTID/comments?limit=5000&access_token=MyAcesstoken

..everything is fine and i get all what i want, BUT when i use this with curl or wget in my terminal on ubuntu.. I just get everytime this:

{"error":{"message":"An access token is required to request this resource.","type":"OAuthException","code":104,

When is use wget I get a bad request and it doesnt work, too.

Please, help me! I cant figure out whats wrong.

Upvotes: 0

Views: 570

Answers (1)

Azeez Kallayi
Azeez Kallayi

Reputation: 2642

Please make sure access token is correct and you are using curl function as intended. I have tested the below code with a valid access token and it is giving me answer. May this help you as well.

$accessToken = 'YourValidAccessToken';
$url = "https://graph.facebook.com/505995689525544_506415109483602/comments?limit=5000&access_token=$accessToken";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
curl_close($curl);
$arr = json_decode($result,true);
print_r($arr);

Upvotes: 2

Related Questions