将图像附加到Facebook事件(php sdk,rest或graph api)

Ada*_*ath 7 php facebook

可能重复:
使用Graph API在facebook事件中添加图片

我现在已经尝试了几个小时来通过带有图像的Facebook API创建一个事件.到目前为止,我已经能够通过Graph和Rest API创建事件而没有图像,但是无法附加任何图像.

我相信REST API是唯一支持附加图像的API,但是文档很差,php-sdk文档或代码也没有多大帮助.

我的最新尝试结束于:http://promos.uk.glam.com/splash_test/example.php

使用代码:http://pastebin.com/8JC8​​RAck(注意"require facebook.php"是php-sdk - http://github.com/facebook/php-sdk/)

注意第93行("if($ uid){"),这应该是"if($ me){",它工作了一个小时左右,然后停止工作(没有更改填充$的代码我,奇怪.

因此,事件创建代码是第96-99行,因为它现在创建了一个没有图像的事件,但是一旦我放回注释掉的代码(第98行),它就无法做任何事情.

有没有人知道如何通过带图像的API在Facebook上创建活动?如果是的话,请帮帮我吧!如果有另一个解决方案,我没有问题废弃所有这些代码,虽然我必须使用PHP或Javascript.

谢谢大家

Ada*_*ath 10

感谢大家的回答,我决定重新审视这个问题,看看API现在是否正常运行.它是!使用Graph API上传图片现在可以正常工作.感谢Stan James将我的注意力集中在这上面并提供了发布照片的代码,我将其用于活动:

建立:

//Setup the Facebook object allowing file upload
$facebook = new Facebook(array(
  'appId'  => 'xxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxx',
  'cookie' => true,
  'fileUpload' => true
));
Run Code Online (Sandbox Code Playgroud)

帖子:

//Path to photo (only tested with relative path to same directory)
$file = "end300.jpg";
//The event information array (timestamps are "Facebook time"...)
$event_info = array(
    "privacy_type" => "SECRET",
    "name" => "Event Title",
    "host" => "Me",
    "start_time" => 1290790800,
    "end_time" => 1290799800,
    "location" => "London",
    "description" => "Event Description"
);
//The key part - The path to the file with the CURL syntax
$event_info[basename($file)] = '@' . realpath($file);
//Make the call and get back the event ID
$result = $facebook->api('me/events','post',$event_info);
Run Code Online (Sandbox Code Playgroud)

我把所有的代码都放在了pastebin上(http://pastebin.com/iV0JL2mL),从我的调试开始有点乱,几个月前对Facebook生气!但它的确有效.