2012-01-29 128 views
0

我整天都在使用Google,并支持此事件?反正,这里是我的代码:如何删除或编辑Facebook活动?

public bool updateEvents(String eventID, EventList toUpdate){ 
      bool success = false; 
      if (String.IsNullOrWhiteSpace(eventID) != false && toUpdate != null) 
      { 
       Dictionary<String, String> eventInit = new Dictionary<string, string>(); 
       DateTime start = DateTime.Parse(toUpdate.StartTime); 
       String startTime = start.ToString("s"); 
       start = DateTime.Parse(toUpdate.EndTime); 
       String endTime = start.ToString("s"); 
       eventInit.Add("name", toUpdate.EventName); 
       eventInit.Add("description", toUpdate.Description); 
       eventInit.Add("start_time", startTime); 
       eventInit.Add("end_time", endTime); 
       eventInit.Add("location", toUpdate.Location); 
       JSONObject js = api.Post(" https://graph.facebook.com/" + eventID, eventInit); 
       if (String.IsNullOrEmpty(js.Dictionary["ID"].String) == false) 
       { 
        success = true; 
       } 
      } 
      return success; 
     } 

public bool deleteEvents(String eventID) 
     { 
      bool success = false; 
      if (String.IsNullOrWhiteSpace(eventID) == false) 
      { 
       JSONObject js = api.Delete("/"+eventID); 
       if (!String.IsNullOrEmpty(js.Dictionary["ID"].String)) 
       { 
        success = true; 
       } 
      } 
      return success; 
     } 

而棘手的部分是,它不更新,如果删除,它返回我一个404

这里有几件事情我已经试过:/ me/events/eventID,http://graph.facebook.com/eventID,/ events/eventID;/eventID;无论如何,它们都不起作用......所以,这可能吗?

回答

0

你在你的代码中的前导空格:用于更新

api.Post(" https:以及一个https://尝试只var js = api.Post(eventId, eventInit);

对于删除你打错检查

  if (!String.IsNullOrEmpty(js.Dictionary["ID"].String)) 
      { 
       success = true; 
      } 

对于HTTP删除命令你从api返回true/false,而不是你删除的id。

+0

程序命中删除功能的那一刻,它会返回一个404,因为我试过了......而这个帖子根本不起作用...... – 2012-01-30 05:57:17