2011-10-07 87 views
7

我创造了我的网站的应用程序,设置动作(读)和客体(条),并放置在对象的代码(在头META标签)在文章页面上我网站。使用与PHP OpenGraph(采取行动cUrl作者请求)

现在,我想知道如何发送每当用户读取我的网站上的一篇文章卷曲的要求,所以它会在他的墙功能。

当我按操作附近的“获取代码”链接,这就是我得到:

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

(有当然的实际访问令牌)。

现在,我怎么做到这一点?

丹尼尔。

回答

10

使用PHP SDK你可以使用api方法。

$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'); 

你也可以做一个原始的请求

$myurl = 'https://graph.facebook.com/me/yellowheart:read? 
      article=http://example.com&access_token=ACCESS_TOKEN&method=post'; 

$result = file_get_contents($myurl); 
+0

你在哪里设置的access_token? – Zorayr

+0

@Zorayr - 我已编辑,以明确地显示在API情况下,配置变量和在原始请求 –

0

我跟着the tutorial“方盒子”,并发现了如何“做到这一点”,在那里一步一步来。希望在某种程度上有所帮助。