Ryan
Ryan

Reputation: 1119

Facebook PHP API date only event

When i create an event with the API and i don't specify a start and end time then facebook automatically adds a time of 10am start and 1am end. Why is it not possible to just add a date only event. When I login to facebook and i create an event there then the time is optional and there is no bogus times added in. Is there an option i am not including in the array that i pass though. Here is some sample code of my request

    $facebook = new Facebook(array(
        'appId' => //key
        'secret' => //secret
    ));

    $facebook->setAccessToken(/*USER ACCESS TOKEN*/);

    try{
        $retObj = $facebook->api('/<USER ID>/events/create', 'POST', array(
            "name" => //title,
            "description" => //description,
            "start_time" => //date only eg. 2013-03-20,
            "end_time" => //date only eg. 2013-03-25
        ));

    } catch(FacebookApiException $e) {
        echo $e->getMessage();
    }

Upvotes: 0

Views: 523

Answers (1)

St&#233;phane Bruckert
St&#233;phane Bruckert

Reputation: 22953

You can't create an event without specifying a start_time, so I don't know how you could have created the event. To create a date-only event, just do:

$retObj = $facebook->api('/<USER ID>/events/create', 'POST', array(
            "name" => "My event", //compulsory field
            "start_time" => "2013-03-19" //tomorrows's date
));

Upvotes: 2

Related Questions