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

Dan*_*iel 7 php facebook facebook-opengraph

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

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

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

curl -F 'access_token=***' \
 -F 'article=http://example.com' \
    'https://graph.facebook.com/me/yellowheart:read'
Run Code Online (Sandbox Code Playgroud)

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

现在,我该如何实现?

丹尼尔.

bri*_*n_d 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');
Run Code Online (Sandbox Code Playgroud)

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

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

$result = file_get_contents($myurl);
Run Code Online (Sandbox Code Playgroud)