Home » Php » facebook – Using OpenGraph with PHP (cUrl requests for actions)

facebook – Using OpenGraph with PHP (cUrl requests for actions)

Posted by: admin July 12, 2020 Leave a comment


I created an app for my website, set action (read) and object (article), and placed the objects code (META tags in the head) at the article page on my website.

Now, I want to know how to send a cUrl request whenever a user reads an article on my website, so it’ll feature on his wall.

When I press the “get code” link near the action, that’s what I get:

curl -F 'access_token=***' \
 -F 'article=http://example.com' \

(There’s an actual access token of course).

Now, how do I make it happen?


How to&Answers:

Using the PHP SDK you would use the api method.

$config = array();
$config['appId'] = 'YOUR_APP_ID';
$config['secret'] = 'YOUR_APP_SECRET';

$facebook = new Facebook($config);

You could also do a raw request

$myurl = 'https://graph.facebook.com/me/yellowheart:read? 

$result = file_get_contents($myurl);





I followed the tutorial “Recipe Box” and found out how to “make it happen” in there step by step. Hope that helps in some way.