Skip to main content
Use PHP 8.1+ named parameters and typed exceptions in Laravel or Symfony workers. Search tweets, export followers or replies, post media, upload files, and send DMs.

Install

If your project needs the GitHub source, add the repository in composer.json. The source repository shows the entry.

Authenticate

Basic example

Search tweets and write durable JSON Lines handoff rows.

PHP SDK workflows

Tweet replies workflow to CSV, JSON, or XLSX

Use this workflow when a PHP worker needs every reply on a public tweet. The worker needs them in a durable file. The file can feed moderation review or customer support triage. It can also feed an analyst export or a warehouse loader. $client->extractions->estimateCost() and $client->extractions->run() map to the extraction workflow. For tweet replies, use ToolType::REPLY_EXTRACTOR. reply_extractor requires targetTweetID. $client->extractions->retrieve() returns results, hasMore, and nextCursor for pagination. $client->extractions->exportResults() returns the completed job as a string. It supports CSV, JSON, and XLSX export formats. Reuse the polling, JSON Lines pagination, and export structure from the follower workflow. Only the tool type, target field, and filenames change.
The cost is 1 credit per reply extracted or returned. Store $job->id on the queue job, ticket, or warehouse batch before polling. With that ID, another worker can resume by calling $client->extractions->retrieve(). Keep $page->nextCursor as the checkpoint. Pass it back as cursor when you stream replies to JSON Lines. Use xquik-replies.jsonl for queue replay or warehouse loads, and xquik-replies.json for app ingestion. Use xquik-replies.csv for CRM import and xquik-replies.xlsx for analyst handoff.

Error handling

The SDK throws subclasses of XTwitterScraper\Core\Exceptions\APIException.

400 Bad request

Throws BadRequestException.

401 Unauthorized

Throws AuthenticationException.

403 Permission denied

Throws PermissionDeniedException.

404 Not found

Throws NotFoundException.

422 Validation error

Throws UnprocessableEntityException.

429 Rate limited

Throws RateLimitException.

5xx server error

Throws InternalServerException.

Pagination

Paginated responses expose fields such as hasNextPage. Pass the endpoint’s cursor fields when requesting more pages.

Webhooks & references