Download the PHP package miladrahimi/twitter-bot without Composer
On this page you can find all versions of the php package miladrahimi/twitter-bot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download miladrahimi/twitter-bot
More information about miladrahimi/twitter-bot
Files in miladrahimi/twitter-bot
Package twitter-bot
Short Description A lightweight and clean implementation of Twitter bot API
License MIT
Homepage https://github.com/miladrahimi/twitter-bot
Informations about the package twitter-bot
Twitter Bot
This package is a basic Twitter bot that handles authentication, HTTP requests and responses, and other primitive requirements. It doesn't focus on any specific Twitter API. Instead, it provides a tool that makes calling Twitter APIs much simpler.
Installation
Install Composer and run the following command in your project's root directory:
Documentation
Getting Started
The snippet below demonstrates how to create an instance of Twitter Bot. It requires your consumer key (API Key) and consumer secret (API Key Secret). You can get them from your Twitter Developer Portal.
Public Endpoints
Public endpoints work without authentication and user tokens. You can call public endpoints like the following sample. This sample shows how to call the search API. It searches for tweets that contain the given hashtag.
Authenticated Endpoints
Authenticated endpoints work only with authenticated user tokens. A user token includes a user token and a user token secret.
If you want to call Twitter APIs on behalf of yourself, you can get your token and token secret from your Twitter Developer Portal. If you need to call Twitter APIs on behalf of other users, you must authorize them before, as mentioned later in this documentation.
This sample shows how to call the update status API and tweet the given text.
JSON APIs
The example below demonstrates how to call APIs with JSON body (like the direct message API). This sample shows how to call sending direct message API and send the given message to the given user.
Uploading Media
You might need to upload media. For example, if you want to tweet a photo, you need to upload it first. The following example illustrates how to upload a photo and tweet it.
Authorize Users (Login with Twitter)
This section explains how to authorize users to get their tokens and token secrets. It's an implementation of "Login with Twitter" indeed.
Request for Token and Redirection Link
First, you must request a user token and confirm your callback URL implicitly (Consider setting your callback URL in your Twitter Developer Portal). Then you can redirect the user to the Twitter website to approve your request (token).
Twitter Callback
When a user approves your request (token) on the Twitter website, Twitter redirects him to your callback URL. In the callback URL, you can verify the token. Then you can use the token for calling Twitter APIs on behalf of the user.
Timeout
In default, the HTTP (cURL) timeout is 10 seconds. You can set your desired timeout (in seconds) like the following example.
License
PhpRouter is initially created by Milad Rahimi and released under the MIT License.
All versions of twitter-bot with dependencies
ext-json Version *
ext-curl Version *