创建Facebook应用
使用cURL发布来自应用的消息,但它似乎是从我发布的?我怎么能从应用程序发布,这是我的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);
帖子有效,但它看起来好像我发布了它而不是App,建议?!
答案 0 :(得分:2)
以下是它适合我的代码
$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);
可能对你有帮助。