[英]How to post to a facebook users wall using the php api with the access token and curl?
Here is what I am currently trying: 这是我目前正在尝试的方法:
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/feed');
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, "access_token=$facebook_access_token&message=testing api.");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
}
where $facebook_access_token is a variable containing the access token. 其中$ facebook_access_token是一个包含访问令牌的变量。
Am I doing something wrong? 难道我做错了什么? I have to use the php api and I do not explicitly know the users facebook page url, only the access token.
我必须使用php api,但我不明确知道用户facebook页面的url,只有访问令牌。
Thanks. 谢谢。
Add one more option to cURL: 向cURL添加一个选项:
CURLOPT_SSL_VERIFYPEER : false CURLOPT_SSL_VERIFYPEER:假
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/feed');
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, "access_token=$facebook_access_token&message=testing api.");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.