The Account Activity API is a webhook-based API that sends account events to a web app you develop, deploy and host.
This is a short instruction, you can read more here:
- Get developer account (if you don't have one apply)
- Setup dev envoriment here
- Prepare application owner access token and access token secret.
Registers a webhook URL for all event types. The URL will be validated via CRC request before saving. In case the validation failed, returns comprehensive error message to the requester. Documentation
// at and ats are application owner access token and access token secret
$client = new Client(['CK', 'CS', 'AT', 'ATS']);
// Your envoriment
$env = 'dev';
// Your webhook url
$url = 'https://example.com/webhook';
// Post to twitter
$client->post('account_activity/all/' . $env . '/webhooks', ['url' => $url]);
Returns all environments, webhook URLs and their statuses for the authenticating app. Currently, only one webhook URL can be registered to each environment. Documentation
// prepare client
$client = new Client(['CK', 'CS']);
// Your envoriment
$env = 'dev';
// Get webhooks
$client->get('account_activity/all/' . $env . '/webhooks');
Removes the webhook from the provided application’s all activities configuration. Documentation
// at and ats are application owner access token and access token secret
$client = new Client(['CK', 'CS', 'AT', 'ATS']);
// Your envoriment
$env = 'dev';
// Your webhook id
$webhook_id = '1234';
// Send a delete request to twitter
$client->delete('account_activity/all/' . $env . '/webhooks/' . $webhook_id);
Triggers the challenge response check (CRC) for the given enviroments webhook for all activites. If the check is successful, returns 204 and reenables the webhook by setting its status to valid. Documentation
// at and ats are application owner access token and access token secret
$client = new Client(['CK', 'CS', 'AT', 'ATS']);
// Your envoriment
$env = 'dev';
// Your webhook id
$webhook_id = '1234';
// Send a put request to twitter
$client->put('account_activity/all/' . $env . '/webhooks/' . $webhook_id);
Subscribes the provided application to all events for the provided environment for all message types. After activation, all events for the requesting user will be sent to the application’s webhook via POST request. Documentation
// at and ats are customers access token and access token secret
$client = new Client(['CK', 'CS', 'AT', 'ATS']);
// Your envoriment
$env = 'dev';
// Send a post request to twitter
$client->post('account_activity/all/' . $env . '/subscriptions');
Provides a way to determine if a webhook configuration is subscribed to the provided user’s events. If the provided user context has an active subscription with provided application, returns 204 OK. If the response code is not 204, then the user does not have an active subscription. See HTTP Response code and error messages below for details. Documentation
// at and ats are customers access token and access token secret
$client = new Client(['CK', 'CS', 'AT', 'ATS']);
// Your envoriment
$env = 'dev';
// Send a post request to twitter
$client->get('account_activity/all/' . $env . '/subscriptions');
Deactivates subscription(s) for the provided user context and application for all activities. After deactivation, all events for the requesting user will no longer be sent to the webhook URL. Documentation
// at and ats are customers access token and access token secret
$client = new Client(['CK', 'CS', 'AT', 'ATS']);
// Your envoriment
$env = 'dev';
// Send a post request to twitter
$client->delete('account_activity/all/' . $env . '/subscriptions');
Returns a list of the current All Activity type subscriptions. Note that the /list endpoint requires application-only OAuth, so requests should be made using a bearer token instead of user context. Documentation
// prepare client
$client = new Client(['CK', 'CS']);
// Your envoriment
$env = 'dev';
// Send a get request to twitter
$client->get('account_activity/all/' . $env . '/subscriptions/list);