Events.create
From Facebook Developer Wiki
Contents |
Description
Creates an event on behalf of the user if the application has an active session key for that user; otherwise it creates an event on behalf of the application. Applications can create events for a user if the user grants the application the create_event extended permission.
If you are creating an event on behalf of a user, then your application is an admin for the event, while the user is the creator.
You can choose to upload an image to associate with the event. See photos.upload for details on supported formats. You can replace or delete images in an event using events.edit.
This method does not require a session key. However if you call this method without an active user session, then your application is both the creator and admin for the event.
Parameters
| Required | Name | Type | Description | |
| required | api_key | string | The application key associated with the calling application. | |
|---|---|---|---|---|
| call_id | float | The request's sequence number. Each successive call for any session must use a sequence number greater than the last. We suggest using the current time in milliseconds, such as PHP's microtime(true) function. | ||
| sig | string | An MD5 hash of the current request and your secret key, as described in the How Facebook Authenticates Your Application. | ||
| v | string | This must be set to 1.0 to use this version of the API. | ||
| event_info | object | The event information, passed as a JSON-encoded object literal. See the Notes below for information on what parameters to include in the object. | ||
| optional | session_key | string | The session key of the logged in user. | |
| format | string | The desired response format, which can be either XML or JSON. (Default value is XML.) | ||
| callback | string | Name of a function to call. This is primarily to enable cross-domain JavaScript requests using the <script> tag, also known as JSONP, and works with both the XML and JSON formats. The function will be called with the response passed as the parameter. | ||
| [no name] | data | The raw image data of the picture to associate with the event. |
Example Requests
Example Code in PHP
Example Return XML
Error Codes
| Code | Description | |
| 1 | An unknown error occurred. Please resubmit the request. | |
|---|---|---|
| 2 | The service is not available at this time. | |
| 4 | The application has reached the maximum number of requests allowed. More requests are allowed once the time window has completed. | |
| 5 | The request came from a remote address not allowed by this application. | |
| 101 | The API key submitted is not associated with any known application. | |
| 102 | The session key was improperly submitted or has reached its timeout. Direct the user to log in again to obtain another key. | |
| 103 | The submitted call_id was not greater than the previous call_id for this session. | |
| 104 | Incorrect signature. |
Notes
You must pass the following parameters in the event_info JSON object literal. The parameters are explained in Event (FQL).
- name
- category
- subcategory
- host
- location
- city
- start_time
- end_time
Note: The start_time and end_time are the times that were input by the event creator, converted to UTC after assuming that they were in Pacific time (Daylight Savings or Standard, depending on the date of the event), then converted into Unix epoch time.
Basically this means for some reason facebook does not want to get epoch timestamps here, but rather something like epoch timestamp minus 7 or 8 hours, depeding on the date. have fun!
Optionally, you can pass the following parameters in the event_info object:
- street
- phone
- page_id
- description
- privacy_type
- tagline
Note: The page_id argument can be used to (see e.g. browser line and find out the id or eid (11 numbers)):
- generate events for groups
- generate events for pages
Note: The privacy_type argument can be one of:
-
OPEN, for an event open and visible to everyone. -
CLOSED, for an event that is visible to everyone but requires an invitation. -
SECRET, for an event that is invisible to those who have not been invited.
So, a sample event_info object would look like this:
