我开始使用 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 是两个变量。 通过这种方式,它为我创建了没有图片的事件。 如何在我的事件中加载图片???? 晚上好!!!再见!
最佳答案
可以考虑使用下面的方案
$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) 找到了解决方案
关于javascript - 使用图片创建 facebook 事件 (Javascript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7869563/