繁体   English   中英

使用OpenGraph和PHP(cUrl请求操作)

[英]Using OpenGraph with PHP (cUrl requests for actions)

我为我的网站创建了一个应用程序,设置了动作(阅读)和对象(文章),并在我网站的文章页面上放置了对象代码(头部的META标签)。

现在,我想知道当用户在我的网站上阅读文章时如何发送cUrl请求,因此它将在他的墙上发布。

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

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

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

现在,我该如何实现?

丹尼尔。

使用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);
$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/

我按照教程 “食谱盒”,一步一步地找到了如何“实现它”。 希望在某种程度上有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM