2010-01-21 62 views

回答

3
public string CreateEvent(string accessToken) 
    { 
     FacebookClient facebookClient = new FacebookClient(accessToken); 
     Dictionary<string, object> createEventParameters = new Dictionary<string, object>(); 
     createEventParameters.Add("name", "My birthday party)"); 
     createEventParameters.Add("start_time", DateTime.Now.AddDays(2).ToUniversalTime().ToString()); 
     createEventParameters.Add("end_time", DateTime.Now.AddDays(2).AddHours(4).ToUniversalTime().ToString()); 
     createEventParameters.Add("owner", "Balaji Birajdar"); 
     createEventParameters.Add("description", " (a long description can be used here..)"); 

     //Add the "venue" details 
     JsonObject venueParameters = new JsonObject(); 
     venueParameters.Add("street", "dggdfgg"); 
     venueParameters.Add("city", "gdfgf"); 
     venueParameters.Add("state", "gfgdfgfg"); 
     venueParameters.Add("zip", "gfdgdfg"); 
     venueParameters.Add("country", "gfdgfg"); 
     venueParameters.Add("latitude", "100.0"); 
     venueParameters.Add("longitude", "100.0"); 
     createEventParameters.Add("venue", venueParameters); 

     createEventParameters.Add("privacy", "OPEN"); 
     createEventParameters.Add("location", "fhdhdfghgh"); 

     //Add the event logo image 
     FacebookMediaObject logo = new FacebookMediaObject() 
     { 
      ContentType = "image/jpeg", 
      FileName = @"C:\logo.jpg" 
     }; 
     logo.SetValue(File.ReadAllBytes(logo.FileName)); 
     createEventParameters["@file.jpg"] = logo; 

     JsonObject resul = facebookClient.Post("/me/events", createEventParameters) as JsonObject; 
     return resul["id"].ToString(); 
    } 

我使用Facebook的API的圖形與FacebookSdk從CodePlex上。

由於Facebook API中存在開放式錯誤,我無法使用此代碼發佈場地。其他事情工作正常。我建議你也實現這個場地參數,以便在facebook解決這個問題後,這個功能就會起作用。

如果它適合您,請將其標記爲答案。它還將幫助其他人節省搜索時間。

相關問題