Chilkat Online Tools

C++ / Twitter API v2 / User Tweet timeline by ID

Back to Collection Items

#include <CkHttp.h>
#include <CkStringBuilder.h>

void ChilkatSample(void)
    {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http;
    bool success;

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken("<access_token>");

    CkStringBuilder sbResponseBody;
    success = http.QuickGetSb("https://api.twitter.com/2/users/:id/tweets",sbResponseBody);
    if (success == false) {
        std::cout << http.lastErrorText() << "\r\n";
        return;
    }

    std::cout << "Response status code = " << http.get_LastStatus() << "\r\n";
    std::cout << sbResponseBody.getAsString() << "\r\n";
    }

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://api.twitter.com/2/users/:id/tweets

Postman Collection Item JSON

{
  "name": "User Tweet timeline by ID",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "https://api.twitter.com/2/users/:id/tweets",
      "protocol": "https",
      "host": [
        "api",
        "twitter",
        "com"
      ],
      "path": [
        "2",
        "users",
        ":id",
        "tweets"
      ],
      "query": [
        {
          "key": "max_results",
          "value": null,
          "description": "Specifies the number of Tweets to try and retrieve, up to a maximum of 100 per distinct request. \n\nRetweets and replies are included in the count, even if `exclude=retweets,replies` are supplied. \n\nBy default, 10 results are returned if this parameter is not supplied. The minimum permitted value is 5.\n",
          "disabled": true
        },
        {
          "key": "start_time",
          "value": null,
          "description": "YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339). The oldest or earliest UTC timestamp from which the Tweets will be provided. Only the 3200 most recent Tweets are available. Timestamp is in second granularity and is inclusive (i.e. 12:00:01 includes the first second of the minute). Minimum allowable time is 2010-11-06T00:00:00Z",
          "disabled": true
        },
        {
          "key": "end_time",
          "value": null,
          "description": "YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339). The oldest or earliest UTC timestamp from which the Tweets will be provided. Only the 3200 most recent Tweets are available. Timestamp is in second granularity and is inclusive (i.e. 12:00:01 includes the first second of the minute). Minimum allowable time is 2010-11-06T00:00:00Z",
          "disabled": true
        },
        {
          "key": "since_id",
          "value": null,
          "description": "Returns results with an ID greater than (that is, more recent than) the specified ID. Only the 3200 most recent Tweets are available. The result will exclude the `since_id`. If the limit of Tweets has occurred since the `since_id`, the `since_id` will be forced to the oldest ID available.",
          "disabled": true
        },
        {
          "key": "until_id",
          "value": null,
          "description": "Returns results with an ID less less than (that is, older than) the specified ID. Only the 3200 most recent Tweets are available. The result will exclude the `until_id`. If the limit of Tweets has occurred since the `until_id`, the `until_id` will be forced to the most recent ID available.",
          "disabled": true
        },
        {
          "key": "pagination_token",
          "value": null,
          "description": "This parameter is used to move forwards or backwards through pages of results, based on the value of the `next_token` or `previous_token` in the response. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.",
          "disabled": true
        },
        {
          "key": "expansions",
          "value": "",
          "description": "Comma-separated list of fields to expand. Expansions enable requests to expand an ID into a full object in the includes response object.\n\nAllowed values: attachments.poll_ids,attachments.media_keys,author_id,geo.place_id,in_reply_to_user_id,referenced_tweets.id,entities.mentions.username,referenced_tweets.id.author_id\n\nDefault values: none",
          "disabled": true
        },
        {
          "key": "tweet.fields",
          "value": "",
          "description": "Comma-separated list of fields for the Tweet object.\n\nAllowed values:\nattachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,organic_metrics,possibly_sensitive,promoted_metrics,public_metrics,referenced_tweets,reply_settings,source,text,withheld\n\nDefault values:\nid,text",
          "disabled": true
        },
        {
          "key": "user.fields",
          "value": "",
          "description": "Comma-separated list of fields for the user object. Expansion required.\n\nAllowed values:\ncreated_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,public_metrics,url,username,verified,withheld\n\nDefault values:\nid,name,username",
          "disabled": true
        },
        {
          "key": "media.fields",
          "value": null,
          "description": "Comma-separated list of fields for the media object. Expansion required.\n\nAllowed values:\nduration_ms,height,media_key,non_public_metrics,organic_metrics,preview_image_url,promoted_metrics,public_metrics,type,url,width\n\nDefault values:\nmedia_key,type",
          "disabled": true
        },
        {
          "key": "place.fields",
          "value": null,
          "description": "Comma-separated list of fields for the place object. Expansion required.\n\nAllowed values:\ncontained_within,country,country_code,full_name,geo,id,name,place_type\n\nDefault values:\nid,full_name",
          "disabled": true
        },
        {
          "key": "poll.fields",
          "value": null,
          "description": "Comma-separated list of fields for the poll object. Expansion required.\n\nAllowed values:\nduration_minutes,end_datetime,id,options,voting_status\n\nDefault values:\nid, options",
          "disabled": true
        }
      ],
      "variable": [
        {
          "key": "id",
          "value": "",
          "type": "string",
          "description": "Required. Enter a single user ID."
        }
      ]
    },
    "description": "Returns the most recent Tweets composed by a single user specified by the requested user ID.\n\nFor full details, see the [API reference](https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-tweets) for this endpoint.\n\n[Sign up](https://t.co/signup) for the Twitter API"
  },
  "response": [
  ]
}