2011-10-23 49 views
2

我開始使用Facebook圖形API來創建javascript事件! 除了圖像以外,它工作得很好。 我以這種方式創建活動:用PICTURE創建一個facebook事件(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兩個變量。 以這種方式,它創造了我沒有圖片的事件。 如何在我的活動中加載圖片? 祝你晚上愉快!再見!

回答

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($結果[「ID」])

我做到了,它完美運作。

ps:感謝Adam Heath在Attach image to Facebook event (php sdk, rest or graph api)發現解決方案