Facebook cURL发布为我? [英] Facebook cURL posting as me?
本文介绍了Facebook cURL发布为我?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建Facebook应用程序
Create facebook app
使用cURL从应用程序发布消息,但它似乎是从我发布的?我可以从应用程序发布,这是我的cURL
Using a cURL to post a message from an App but it's appearing to be posted from me? How can I can it to post from the app, here's my cURL
$attachment = array(
'access_token' => $token,
'message' => '$message',
'name' => '$name',
'link' => '$link',
'description' => '$description',
'picture'=> '$picture',
'actions' => json_encode(array('name' => '$name2','link' => '$link2'))
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$pId.'/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);
这篇文章的工作,但它只是看起来好像我发布,而不是应用程序,建议?
The post works, but it just appears as if I posted it and not the App, suggestions?!
推荐答案
以下是适用于我的代码
$file = 'image.jpg';
$args = array(
'message' => 'Photo from application',
'access_token'=>urlencode('Your Access token'),
);
$args[basename($file)] = '@'.realpath($file);
$ch = curl_init();
$url = 'https://graph.facebook.com/me/photos';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$result = curl_exec($ch);
curl_close ($ch);
也许可以帮助你。
这篇关于Facebook cURL发布为我?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文