Facebook API php-将新闻项目发布到Facebook组

*strong text*I have a website that publishes articles every day.

I want to have a corresponding Facebook group that I can publish the articles to at the same time as on my site.

I have set up a similar arrangement in twitter using the api. When I publish an article to my site I it automatiaclly posts the headline and link back to twitter via the twitter API. I would like to have a similar arrangement for my facebook group.

Is it possible to have my stories forwarded to my facebook group wall?

EDIT

Ok, I have gotten this far, and no further:

Step 1: Get authorisation to publish to the stream

if ($fp = fopen('https://graph.facebook.com/oauth/access_token?client_id=XXXXXXXXXX&client_secret=XXXXXXXXXXXXtype=client_cred&scope=publish_stream', 'r')) {
    $content = '';
    // keep reading until there's nothing left
    while ($line = fread($fp, 1024)) {
        $content .= $line;
    }
    $tokens = explode("access_token=",$content);

    // do something with the content here
    $auth_token = $tokens[1];
    fclose($fp);


} else {
    // echo" an error occured when trying to open the specified url";
}

Step 2: send my message to the stream using my authorisation code (I have chosen to use cURL):

 $message="This will be a post on my groups wall.";
$url = "https://graph.facebook.com/my_app_id/feed";

$data = array('message' => $message, 'auth_token' => $auth_token);

$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

if (empty($buffer))
{
    print "Nothing seems to have happened";
}
else
{
    print $buffer;
}

The code runs with no errors, but nothing gets returned and nothing gets posted to the wall

any ideas?

#0

Facebook treats pages similar to the way they treat people, you specify a UID which is associated with the Page ID of your group. Then just use Facebook's Graph API to post to the stream, just as you would a person.

To authorize, you get Facebook API permission from an admin and request the manage_pages permission.

All of the information you need is contained here: https://developers.facebook.com/docs/reference/api/#impersonation.

(Ctrl+F Page Login for more information on authorizing to update to pages).

推荐文章

WP7-检测映射多边形上的“单击”事件

WP7-检测映射多边形上的“单击”事件

推荐文章

python中的Google量表(reportlab)

python中的Google量表(reportlab)

推荐文章

从ByteBuffer中提取字符串-我很困惑

从ByteBuffer中提取字符串-我很困惑

推荐文章

getUploadedBlobs方法的奇怪行为

getUploadedBlobs方法的奇怪行为

推荐文章

如何仅使用用户帐户id创建adsense广告?

如何仅使用用户帐户id创建adsense广告?

推荐文章

后置和预递增运算符的优先级

后置和预递增运算符的优先级

推荐文章

从Spring安全表达式调用静态方法?

从Spring安全表达式调用静态方法?

推荐文章

Android:如何将Android本机代码中的数据传递给jquerymobile

Android:如何将Android本机代码中的数据传递给jquerymobile

推荐文章

Symfony 1.4中fixtures文件的加载顺序是什么

Symfony 1.4中fixtures文件的加载顺序是什么

推荐文章

从自定义对象数组中提取唯一值

从自定义对象数组中提取唯一值

推荐文章

protobuf-net的[ProtoInclude(1,“MyClass”)]不起作用

protobuf-net的[ProtoInclude(1,“MyClass”)]不起作用

推荐文章

在目标c中自动调用类方法

在目标c中自动调用类方法

推荐文章

iphone phonegap应用程序上的youtube视频

iphone phonegap应用程序上的youtube视频

推荐文章

一般Android半透明错误

一般Android半透明错误

推荐文章

“简单”的PHP脚本,使用无模块、无包、无flash显示进度上传

“简单”的PHP脚本,使用无模块、无包、无flash显示进度上传

推荐文章

为什么LLVM会抱怨缺少函数原型?

为什么LLVM会抱怨缺少函数原型?