Link to plugin page: https://zeroqode.com/plugin/advanced-twitter-api-1580388207316x240833466550325570
Introduction
Many endpoints on the Twitter developer platform use the OAuth 1.0a method to act, or make API requests, on behalf of a Twitter account. For example, if you have a Twitter developer app, you can make API requests on behalf of any Twitter account as long as that user authenticates your app.
The plugin can do the following actions:
Prerequisites
You must have a developer account with Twitter to interact with the plugin. Create your development account at:
https://developer.twitter.com/en/dashboard
How to setup
I. How to get Keys
The keys that you need are in your Twitter developer account(https://developer.twitter.com) -> Developer portal -> Projects & Apps tab -> Your app -> Keys and Tokens
Plugin field ConsumerPublic and ConsumerSecret are Consumer Keys from the dev account.
Same for Access tokens, access level should be Read, Write and Direct Messages.
Don't forget to add all urls from which the authorization window will be called. Including test versions.
To add redirect URL for authentification go to Twitter developer account (https://developer.twitter.com) -> Developer portal -> Projects & Apps tab -> Your app -> Settings -> User authentication settings -> Edit
Add ALL possible URLs
II. Setting up Keys in Plugin Settings
When you've got your keys from Developer Account, place them in plugin settings fields as shown:
III. Get OAuth tokens
- Request new token and authorize user
At the first step, the user should give access to his account, for that on a button click (or other user interaction you want) set the first action to Twitter: Get tokens
This action is used in 2 steps, at first step set field Auth current step to step_1
For step_1 also set a callback URL encoded at field Step 1: Callback URL
Leave empty other fields, will be used later in another workflow.
Right after that set the next plugin action, Authorize user.
For the Oauth token field, set the Result of step 1 (Get tokens) Step 1 Oauth token:
2. Generate and save user’s tokens
These actions will redirect the user to the Twitter authorization page. When the user is redirected back to your application, there are 2 events that should be configured.
- The Event when the user denied access to your application, it is called Twitteraccount A User denied access, and you can do whatever you want to warn the user about it.
2. The user gave access and tokens from the callback are ready to use here on the first action set Twitter:Get tokens (same action from step_1).
But set fields for step_2
Next, save the obtained tokens to the current user. For example:
To refresh tokens, set the same actions from step 1:
Plugin Events List
- A Twitter account Callback Tokens ready: Event used when account callback token is available
- A Twitter account User denied access: Event used when user account is denied access
Plugin Actions List
- Twitter: Post New Tweet
- Twitter: Delete Tweet
- Twitter: Retweet Or Cancel Retweet
- Twitter: Like Tweet
- Twitter: Load Timeline
- Twitter: Get User Details
- Twitter: Get Tokens
- Twitter: Search Tweets
- Twitter: Upload Picture
- Twitter: Post With Picture
- Twitter: Upload GIF
- Twitter: Post With GIF
- Twitter: Upload Video
- Twitter: Post With Video
- Authorize User With A Twitter Account
- Twitter: Get a list of friends
- Twitter: Get a list of followers
- Twitter: Follow
- Twitter: Unfollow
- Twitter: Update profile image
- Twitter: Update profile data
- Twitter: Update banner image
- Twitter: Get next page of friends
- Twitter: Get previous page of friends
Plugin Element Proprieties
This plugin has visual element Twitter account which should be used on page.
Element Properties: No properties
Element Events
- Callback Tokens ready: this event is triggered once the tokens from the Twitter: Get tokens action Step 1 are ready and can be used. Use this event to trigger Step 2 of Twitter: Get tokens action.
- User denied access: this event is triggered if the user is denied access to Twitter.
Element Actions
Authorize user: the action to be called once Step 1 of the Twitter: Get tokens plugin action has finished executing
Properties
Element Exposed States
- Callback OAuth token: Callback OAuth token to be used in Step 2 of Twitter: Get tokens action.
- Callback OAuth verifier: Callback OAuth verifier to be used in Step 2 of **Twitter: Get tokens **action.
PLUGIN ACTIONS DETAILED
Actions
- Get tokens - current authorization step.
Step 1: Callback URL: The value that will be used as the URL a user is redirected to should they approve your application’s access to their account. Is used only if the previous property is set to ‘step_1’.
Step 2: Callback OAuth token: OAuth token here must be the same as the oauth_token returned in step_1. You can get it from the TwitterAccount element’s ‘Callback OAuth token’ state. Is used only if the previous property is set to ‘step_2’.
Step 2: Callback OAuth verifier: OAuth verifier returned in the callback URL. You can get it from the TwitterAccount element’s ‘Callback OAuth verifier’ state. Is used only if the previous property is set to ‘step_2’.
Fields:
Title | Description | Type |
Auth current step | step_1 or step_2 | Dropdown |
Step 1: Callback URL | Insert in this field when running step 1. Url encoded | string (optional) |
Step 2: Callback Oauth token | Insert in this field when running step 2 | string (optional) |
Step 2: Callback Oauth verifier | Insert in this field when running step 2 | string (optional) |
Returned Values:
Title | Description | Type |
error | URL of the page to open | string |
Step 1: Oauth token | OAuth token obtained on this step. | string |
Step 1: Oauth token secret | OAuth token secret obtained on this step. | string |
Step 1: Oauth callback confirmed | ‘yes’ if the OAuth callback was confirmed, or ‘no’ if it was not confirmed. | yes/no |
Step 2: Oauth token | OAuth token obtained on step 2. | string |
Step 2: Oauth token secret | OAuth token secret obtained on step 2. | string |
Step 2: User ID | User ID: ID of the user. | string |
Step 2: Username | username (screen name) of the user. | string |
- Post a tweet - Updates the authenticating user's current status, also known as Tweeting.
Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Text | Text Tweet. Max 280 characters | string |
Returned values:
Title | Description | Type |
Tweet ID | ID of the newly created tweet. | string |
- Delete a tweet - Destroys the status specified by the required ID parameter. The authenticating user must be the author of the specified status.
Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Tweet ID | ID of the tweet that you want to delete | string |
Returned values:
Title | Description | Type |
Success | ‘yes’ in case of success, ‘no’ in case of error. | yes/no |
Error | error message in case of an error. | string |
- Retweet or cancel a retweet - Retweets a tweet. Returns the original Tweet with Retweet details embedded.
Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Tweet ID | ID of the tweet that you want to retweet | string |
Action | Retweet or Cancel retweet | Dropdown |
Returned values:
Title | Description | Type |
Success | ‘yes’ in case of success, ‘no’ in case of error. | yes/no |
Error | error message in case of an error. | string |
- Like a tweet - Favorites (likes) the Tweet specified in the ID parameter as the authenticating user. Returns the favorite Tweet when successful.
Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Tweet ID | ID of the tweet that you want to like | string |
Action | Like or Remove like | Dropdown |
Returned values:
Title | Description | Type |
Success | ‘yes’ in case of success, ‘no’ in case of error. | yes/no |
Error | error message in case of an error. | string |
- Search tweets - Is used to return public statuses that match specified keywords. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Keywords | A comma-separated list of phrases or words. Punctuation and special characters will be considered part of the term they are adjacent to. | string |
Returned values:
Title | Description | Type |
Results | results for the given request in case of a successful response. | string |
Error | error message in case of an error. | string |
- Load timeline - Returns a collection of the most recent Tweets posted by the authenticating user and the users they follow.
Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Timeline | Load current user tweets or his home timeline
(user or home) | Dropdown |
Returned values:
Title | Description | Type |
Tweet text list | a list of tweet texts | string |
Tweet object list | a list of tweet objects | string |
Tweet posted by list: | a list of tweet authors names | string |
Tweet list posted favorite | displays the number of favorite | string |
Tweet list posted retweet | displays the number of retweet | string |
Error | error message in case of an error | string |
- Get user's details - Is used to test if supplied user credentials are valid. Returns a 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not.
Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Request user email (deprecated) | Your app will need to regenerate the user access tokens for previously authenticated users to access their email address.The "Request email addresses from users" checkbox is available under the app permissions on developer.twitter.com | Checkbox |
Returned values:
Title | Description | Type |
User ID | ID of the requesting user | string |
Name | name of the requesting user | string |
Screen Name | screen name of the requesting user | string |
Description | description for the requesting user | string |
Url | URL | string |
Followers count | followers count for the requesting user | number |
Friends count | friends count for the requesting user | number |
Listed count | listed count for the requesting user | number |
Created date | the date when the requesting user was created | date |
Favorites count | favorites count for the requesting user | number |
Is verified | ‘true’ if the requesting user is verified, otherwise ‘false’ | yes/no |
Statuses count | statuses count for the requesting user | number |
Last status text | last status text of the requesting user | text |
Last status date | the date of the last status for the requesting user | data |
Last status id | ID of the last status for the requesting user | text |
Profile image url | profile image URL for the requesting user | text |
Profile banner url | profile banner URL for the requesting user | text |
User email | requesting user email | text |
Error | error message in case of an error | text |
- Post a tweet with gif - Updates the authenticating user's current status with gif, also known as Tweeting.
Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Gif id | Id Gif that you want to tweet | string |
Tweet text | Text Tweet. Max 280 characters | string |
- Post a tweet with video - Is used to post a tweet with a video previously uploaded to Twitter.
Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Media id for the video | Id Video that you want to tweet | string |
Tweet text | Text Tweet. Max 280 characters | string |
Returned values:
Title | Description | Type |
tweet_id | ID of the newly created tweet. | string |
error | error message in case of an error. | string |
- Get a list of friends - Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends"). Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
User ID | The ID of the user for whom to return result. | number |
Screen Name | The screen name of the user for whom to return results. | string |
Cursor | Causes the results to be broken into pages. If no cursor is provided, a value of -1 will be assumed, which is the first "page." The response from the API will include a previous_cursor and next_cursor to allow paging back and forth. See Using cursors to navigate collections for more information. | string (optional) |
Count | The number of users to return per page, up to a maximum of 200. | number (optional) |
Skip Status | When set to either YES, t or 1 statuses will not be included in the returned user objects. | yes/no (optional) |
Include User Entities | The user object entities node will not be included when set to NO. | yes/no (optional) |
User Type | Specify the data type as Friends (Twitter) for proper parsing | App type |
Returned values:
Title | Description | Type |
Error | error message in case of an error. | string |
Users | list Of Users | as User Type |
Previous Page | number previous page cursor | text |
Next Page | number next page cursor | text |
- Get a list of followers - Returns a cursored collection of user objects for users following the specified user. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
User ID | The ID of the user for whom to return result. | number |
Screen Name | The screen name of the user for whom to return results. | string |
Cursor | Causes the results to be broken into pages. If no cursor is provided, a value of -1 will be assumed, which is the first "page." The response from the API will include a previous_cursor and next_cursor to allow paging back and forth. See Using cursors to navigate collections for more information. | string (optional) |
Count | The number of users to return per page, up to a maximum of 200. | number (optional) |
Skip Status | When set to either YES, t or 1 statuses will not be included in the returned user objects. | yes/no (optional) |
Include User Entities | The user object entities node will not be included when set to NO. | yes/no (optional) |
User Type | Specify the data type as followers (Twitter) for proper parsing | App type |
Returned values:
Title | Description | Type |
Error | error message in case of an error. | string |
Users | list Of Users | as User Type |
Result | response request <followers/list> | string |
Previous Page | number previous page cursor | string |
Next Page | number next page cursor | string |
- Send Direct Message - Publishes a new
message_create
event resulting in a Direct Message sent to a specified user from the authenticating user. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Recipient ID | The ID of the user who should receive the direct message. | string |
Message | The Message Data Object defining the content to deliver to the reciepient. | string |
Returned values:
Title | Description | Type |
Error message | error message in case of an error. | string |
Status code | response status code | string |
- Get Direct Messages - Returns all Direct Message events (both sent and received) within the last 30 days. Sorted in reverse-chronological order. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Message type | Type a message | App Type |
Returned values:
Title | Description | Type |
Error message | error message in case of an error. | string |
App type | list messages | app type |
- Update profile image - Updates the authenticating user's profile image. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
New Image url | Image url that you want to update profile | image |
Returned values:
Title | Description | Type |
Error | error message in case of an error. | string |
status | response status (success or fail) | string |
- Update profile data - Sets some values that users are able to set under the "Account" tab of their settings page. Only the parameters specified will be updated. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Name | Full name associated with the profile. | string (optional) |
Location | The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. | string (optional) |
Description | A description of the user owning the account. | string (optional) |
Returned values:
Title | Description | Type |
error | error message in case of an error. | string |
status | response status (success or fail) | string |
- Update banner image - Uploads a profile banner on behalf of the authenticating user. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
New Image url | Image url being uploaded as the user's new profile banner. | image |
Returned values:
Title | Description | Type |
error | error message in case of an error. | string |
status | response status (success or fail) | string
|
- Upload Picture - Is used to upload a picture to Twitter. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Image | Image url | image |
Returned values:
Title | Description | Type |
error | error message in case of an error. | string |
media_id | ID of the uploaded image. | string |
- Post With Picture - Is used to post a tweet with a picture previously uploaded to Twitter. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Image id | media id of the image uploaded to Twitter, obtained as the result of the ‘Twitter: Upload picture’ action. | string |
Tweet text | text to the new tweet. | string |
Returned values:
Title | Description | Type |
error | error message in case of an error. | string |
tweet_id | ID of the newly created tweet. | string |
- Upload GIF - Is used to upload a GIF to Twitter. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Image id | media id of the image uploaded to Twitter, obtained as the result of the ‘Twitter: Upload picture’ action. | string |
Tweet text | text to the new tweet. | string |
Returned values:
Title | Description | Type |
error | error message in case of an error. | string |
media_id | ID of the uploaded GIF. | string |
status | status of the upload. | string |
- Upload Video - Is used to upload a video to Twitter. Fields:
Title | Description | Type |
Oauth from Step 2 | Oauth token | string |
Oauth secret from Step 2 | Oauth secret token | string |
Video file | link to the video file (in most cases, Bubble File Uploader’s value). | string |
Returned values:
Title | Description | Type |
error | error message in case of an error. | string |
media_id | ID of the uploaded video. | string |
status | status of the upload. | string |
Plugin States
Workflow example
Action Example - Post new tweet
To post a new tweet use action, Twitter: Post new tweet.
For this and other actions you need OAuth tokens from Step_2, you should have them saved by now, in the current user database.
This action returns the posted tweet ID, you can get it using the Result of step 1: Tweet ID
The same tokens are used for other actions.
Action Example - Post a new tweet with a picture
To post a new tweet with a picture you require two actions: Twitter: Upload picture and Twitter: Post with picture.
For both of these actions you need OAuth tokens from Step_2, you should have them saved by now in the current user database.
For the first action you’ll also need an image (up to 5 Mb) uploaded to the app using File Uploader:
For the second action you’ll need to use media_id from the previous action as the ‘Image id’, and the tweet text:
This action returns posted tweet ID, you can get it using the Result of step 2 (Twitter: Post with picture): tweet_id
Action Example - Post a new tweet with GIF
To post a new tweet with GIF, just like for posting a tweet with a picture you have to use two actions: Twitter: Upload GIF and Twitter: Post with GIF.
Set them up just the way the actions for tweeting with a picture in the above example.
For the first action you’ll also need an animated gif uploaded to the app using File Uploader:
For the second action you’ll need to use Gif_id from the previous action as the ‘Gif id’, and the tweet text:
This action returns the posted tweet ID, you can get it from Result of step 2 (Twitter: Post with GIF): tweet_id.
Animated GIF recommendations
The GIF file size must not exceed 15 Mb.
A GIF may fail during Tweet creation even if it is within the file size limit. Adhere to the following constraints to improve success rates.
- Resolution should be <= 1280x1080 (width x height)
- Number of frames <= 350
- Number of pixels (width * height * num_frames) <= 300 million
- File size <= 15Mb
Action Example - Post new tweet with a video
To post a new tweet with a video, like for posting a tweet with a picture or GIF, you have to use two actions: Twitter: Upload video and Twitter: Post with video.
Set them up just the way the actions for tweeting with pictures or GIFs in the above examples are set.
For the first action you’ll need a video file (up to 15 Mb, up to 140 seconds) uploaded to the app using File Uploader:
For the second action you’ll need to use media_id from the previous action as the ‘Media ID for the video’, and the tweet text:
This action returns the posted tweet ID. You can get it from the Result of step 2 (Twitter: Post with video): tweet_id
Video specifications and recommendations
The video file size must not exceed 15 Mb.
The video duration must be between 0.5 seconds and 140 seconds.
It may fail during upload to Twitter even if it is within the file size and the duration limit. Adhere to the following constraints to improve success rates.
- Recommended Video Codec: H264 High Profile
- Recommended Frame Rates: 30 FPS, 60 FPS
- Recommended Video Resolution: 1280x720 (landscape), 720x1280 (portrait), 720x720 (square)
- Recommended Minimum Video Bitrate: 5,000 kbps
- Recommended Minimum Audio Bitrate: 128 kbps
- Recommended Audio Codec: AAC LC
- Recommended Aspect Ratio: 16:9 (landscape or portrait), 1:1 (square)
Changelogs
Update 24.07.20 - New Actions
- Twitter: Upload a picture
- Twitter: Post with a picture
Update 18.08.20 - New Actions
- Twitter: Upload GIF
- Twitter: Post with GIF
Update 13.11.20 - New Actions
- Twitter: Upload Video
- Twitter: Post with Video
Update 13.10.21 - New Actions
- Twitter: Get a list of friends
- Twitter: Get a list of followers
Update: 13.11.20 -
- Added possibility to post a tweet with video. Improved tweet with GIF support gifs up to 15Mb.
Update: 13.06.21
- Added new actions for adding threads
Update: 13.10.21
- Added new actions for getting lists of friends and followers
Update: 06.01.22 - Version: 1.12.0.
- Added follow/unfollow actions
Update: 30.04.22 - Version: 1.13.0.
- Added new action to send direct messages
Update: 04.05.22 - Version: 1.14.0.
- Added a new action to get a list of messages
Update 12.10.22 - Version 1.15.0
- Fixed "Load timeline" action.
- Added “Update profile image”, “Update profile data”, “Update banner image” actions, and "previous_page" and "next_page" returned values.
- Updated "Get a list of friends" and "Get a list of followers" actions.
Update 18.10.22 - Version 1.16.0
- Minor fixes