将OpenGraph与PHP一起使用(对操作的cUrl请求) [英] Using OpenGraph with PHP (cUrl requests for actions)

查看:419
本文介绍了将OpenGraph与PHP一起使用(对操作的cUrl请求)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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' \
    'https://graph.facebook.com/me/yellowheart:read'

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

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

现在,我该如何实现?

丹尼尔.

推荐答案

使用PHP SDK,您可以使用

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

这篇关于将OpenGraph与PHP一起使用(对操作的cUrl请求)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆