Twitter: Get Likes

Posted by agiletortoise, Last update 12 months ago

NOTE: This action no longer functions due to policy changes at Twitter that are out of our control. Visit the Twitter integration guide for details.

Prompt for a Twitter handle, the request a list of their recent likes from the Twitter API. Build a Markdown version of those tweets, put them in a new draft and open it in the editor.

Demonstrates use of the Twitter object request method to make arbitrary requests to the Twitter API.


  • script

    // set default twitter screen name for prompt
    var screenName = "agiletortoise";
    // prompt to screen to query for recent favs/likes
    var p = Prompt.create();
    p.title = "Get Twitter Likes"
    p.message = "Enter twitter handle for the account who's likes you wish to download";
    p.addTextField("user", "User", screenName);
    p.addButton("Get Likes");
    if ( {
    	screenName = p.fieldValues["user"];
    else {
  • script

    // create a Twitter object
    var twitter = Twitter.create();
    // construct API endpoint to use.
    // information on API at
    var baseURL = "";
    var url = baseURL + "favorites/list.json";
    // make request to Twitter API
    var response = twitter.request({
    	"url": url,
    	"method": "GET",
    	"parameters": {
    		"screen_name": screenName
    // handle the response
    if (response.statusCode == 200) {
    	var content = "";
    	// favorites return array of tweet objects
    	// loop over them and build a Markdown version
    	for (var fav of response.responseData) {
    		var id = fav.id_str;
    		var sn = fav.user.screen_name;
    		var tweetURL = `${sn}/status/${id}`;
    		var text = fav.text;
    		content += `${text}\n*[link](${tweetURL})*\n\n---\n\n`
    	// create a new draft and open it
    	var d = Draft.create();
    	d.content = content;
    else {;


  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.