Install
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.$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 ofXTwitterScraper\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 ashasNextPage. Pass the endpoint’s cursor fields when requesting more pages.