使用 cURL PHP 发布到 Facebook 用户的墙上 [英] Post to a Facebook user's wall with cURL PHP

查看:30
本文介绍了使用 cURL PHP 发布到 Facebook 用户的墙上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在存储 Facebook 用户 ID 和访问令牌.我可以将这些信息发布到选定用户的墙上吗?以下代码位于此处:http://developers.facebook.com/docs/reference/api/post/我只是不确定如何使用 php 运行它.

I'm storing facebook userid's and access tokens. Can i post to a selected user's wall with this information? The following code is found here: http://developers.facebook.com/docs/reference/api/post/ I'm just not sure how to run it with php.

curl -F 'access_token=$accessToken' 
     -F 'message=Check out this funny article' 
     -F 'link=http://www.example.com/article.html' 
     https://graph.facebook.com/$facebookid/feed

推荐答案

$attachment =  array(
'access_token' => $token,
'message' => $msg,
'name' => $title,
'link' => $uri,
'description' => $desc,
'picture'=>$pic,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/fbnameorid/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output 
$result = curl_exec($ch);
curl_close ($ch);

这篇关于使用 cURL PHP 发布到 Facebook 用户的墙上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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