2011-06-16 52 views
1

我想用Graph API和PHP發佈一個事件給我的Facebook配置文件。 我已成功創建了一個活動,但未將其發佈到我的個人資料中,但僅發佈在我的應用頁面上。 fb-app是該事件的創建者,但我希望自己的個人資料成爲創建者,並且我希望它能夠在我的Feed上顯示。我怎樣才能做到這一點?在facebook上發佈事件與php的配置文件

$token = file_get_contents('https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET'); 
$ch=curl_init('https://graph.facebook.com/MY_PROFILE_ID/events'); 
curl_setopt($ch, CURLOPT_POSTFIELDS, "name=test event&start_time=2011-07-16T19:20&location=someplace&".$token.""); 
curl_exec($ch); 
curl_close($ch); 
+0

你不能使用PHP SDK和發送從SDK的要求?幾個小時前我使用SDK獲得了它的工作,很好。 – 2011-06-17 02:07:15

+1

謝謝facebook PHP SDK對我來說非常好! – waterschaats 2011-06-17 11:45:55

回答

0

我使用PHP SDK ...

$eventInfo = array(
      'name'   => 'name', 
      'description' => strip_tags('description'), 
      'owner'   => 'Owner', 
      'location'  => 'Location name and street', 
      'city'   => 'city', 
      'start_time' => 'starttime', 
      'end_time'  => 'endtime', 
      'privacy_type' => 'OPEN' 
     ); 
$microFlyerBig = 'http://www.example.com/www/img/img.jpg'; 
$eventInfo[basename($microFlyerBig)] = "@" . realpath($microFlyerBig); 
$fbEventId = $facebook->api("/me/events", "post", $eventInfo); 
$fbEventId = $fbEventId['id']; 
相關問題