当前位置: 动力学知识库 > 问答 > 编程问答 >

facebook graph api - Creating an event without an end_time

问题描述:

I am trying to figure out how to create a new event without specifying an end_time. This has worked successfully in the Graph API Explorer, but not in my JavaScript code.

FB.api('/me/events?access_token=' + accessToken,'post',{name: retVal.name, start_time: retVal.start_time, location: retVal.location, description: retVal.description, privacy: 'SECRET'},function(retVal) {});

If I include an end_time, it works perfectly. But if not, I get '(#100) An event cannot have an end time before its start time.' There has to be a way to do this. My customers may not always want to specify an end time for whatever event they happen to be creating, and it might annoy them slightly if I put one in there for them.

Thanks

网友答案:

This works for me:


FB.api('/me/events','post',{name:"SomeTestEvent",start_time:1272718027,location:"my_location"},function(resp) {
    console.log(resp);
});

Note: you need to have extended permission "create_event" as well.

Hope it helps

网友答案:

So... here's the deal. Basically, I'm an idiot. What I didn't catch in my testing is that the database for my local events requires an end_date, so it was using the start_date if one was not supplied. I had an if statement in the logic to check if the end_date was empty, which in this case it never was. So the API call was passing the same values in for both start and end, throwing the error.

That's what happens when you're working late at night...

分享给朋友:
您可能感兴趣的文章:
随机阅读: