Using OpenGraph with PHP (cUrl Requests for Actions)

I created an application for my website, installed an action (reading) and an object (article) and placed the code of objects (META tags in my head) on 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 will be displayed on his wall.

When I click the β€œget code” link next to the action, this is what I get:

curl -F 'access_token=***' \ -F 'article=http://example.com' \ 'https://graph.facebook.com/me/yellowheart:read' 

(Of course, there is an access token).

Now how do I do this?

Daniel

+7
source share
3 answers

Using the PHP SDK, you should use the api method.

 $config = array(); $config['appId'] = 'YOUR_APP_ID'; $config['secret'] = 'YOUR_APP_SECRET'; $facebook = new Facebook($config); ... $facebook->api('https://graph.facebook.com/me/yellowheart:read? article=http://example.com'','POST'); 

You can also execute a raw request

 $myurl = 'https://graph.facebook.com/me/yellowheart:read? article=http://example.com&access_token=ACCESS_TOKEN&method=post'; $result = file_get_contents($myurl); 
+10
source
 $facebook->api('/me/'.FB_NAME_SPACE.':action','POST', array('facility'=>'http://www.mysite.com/object?id=1') ); 

https://developers.facebook.com/docs/reference/php/facebook-api/

+1
source

I followed the Recipe tutorial and figured out how to "do it" there step by step. Hope this helps.

0
source

All Articles