如何删除或编辑Facebook活动?

时间:2012-01-29 13:20:43

标签: asp.net facebook-graph-api

我整天都在谷歌上搜索,这个活动是否受到支持?无论如何,这是我的代码:

 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;无论如何,它们都不起作用......所以,它有可能吗?

1 个答案:

答案 0 :(得分: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。

相关问题