我开始使用facebook graph api用javascript创建事件! 除图像外,它的效果非常好。 我以这种方式创建活动:
FB.api("/"+idOwner+"/events?access_token="+access_token,'post',{
name: 'TEST',
start_time: '2011-12-01T15:00:00',
privacy_type:"OPEN",
end_time: '2011-12-02T15:00:00',
location: 'here',
picture: 'http://www.ostianews.it/wp-content/uploads/2010/06/rock.jpg'
});
idOwner和access_token是两个变量。 通过这种方式,它创造了我没有图片的事件。 如何在我的活动上加载图片???? 祝大家晚安!再见!
答案 0 :(得分:1)
您可以考虑使用以下解决方案
$photo = './images/logo-square.png';// Must be an image on your server
$event_info = array(
"privacy_type" => "OPEN",
"name" => "Event Title",
"page_id" => YOUR_PAGE_ID,
"start_time" => "2012-01-22 09:00:00",
"end_time" => "2012-02-22 09:00:00",
"description" => "Event Description"
);
//The key part - The path to the file with the CURL syntax
$event_info[basename($photo)] = '@' . realpath($photo);
//Make the call and get back the event ID
$result = $this->facebook->api($this->id.'/events','post',$event_info);
如果您绝对想在JS中做,请创建一个ajax来执行此代码并返回事件ID($ result [“id”])
我做到了,它完美无缺。
ps:感谢Adam Heath在Attach image to Facebook event (php sdk, rest or graph api)
找到解决方案