Chilkat Online Tools

PureBasic / Twitter API v2 / Recent Tweet counts

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"

Procedure ChilkatExample()

    ; This example assumes the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    queryParams.i = CkJsonObject::ckCreate()
    If queryParams.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckUpdateString(queryParams,"query","")

    ; Adds the "Authorization: Bearer <access_token>" header.
    CkHttp::setCkAuthToken(http, "<access_token>")

    resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://api.twitter.com/2/tweets/counts/recent",queryParams)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(queryParams)
        ProcedureReturn
    EndIf

    Debug Str(CkHttpResponse::ckStatusCode(resp))
    Debug CkHttpResponse::ckBodyStr(resp)
    CkHttpResponse::ckDispose(resp)



    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(queryParams)


    ProcedureReturn
EndProcedure

Curl Command

curl -G -d "query="
	-H "Authorization: Bearer <access_token>"
https://api.twitter.com/2/tweets/counts/recent

Postman Collection Item JSON

{
  "name": "Recent Tweet counts",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "https://api.twitter.com/2/tweets/counts/recent?query=",
      "protocol": "https",
      "host": [
        "api",
        "twitter",
        "com"
      ],
      "path": [
        "2",
        "tweets",
        "counts",
        "recent"
      ],
      "query": [
        {
          "key": "query",
          "value": "",
          "description": "Required. Query for matching Tweets. Up to 512 characters."
        },
        {
          "key": "start_time",
          "value": "",
          "description": "The oldest UTC timestamp (from most recent 7 days) from which the Tweets will be provided. YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339).",
          "disabled": true
        },
        {
          "key": "end_time",
          "value": "",
          "description": "The newest, most recent UTC timestamp to which the Tweets will be provided. YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339).",
          "disabled": true
        },
        {
          "key": "since_id",
          "value": "",
          "description": "Returns results with a Tweet ID greater than (that is, more recent than) the specified ID. The ID specified is exclusive and responses will not include it.",
          "disabled": true
        },
        {
          "key": "until_id",
          "value": "",
          "description": "Returns results with a Tweet ID less than (that is, older than) the specified ID. The ID specified is exclusive and responses will not include it.",
          "disabled": true
        },
        {
          "key": "granularity",
          "value": null,
          "description": "This is the granularity that you want the timeseries count data to be grouped by. Possible values are day, hour or minute. The default granularity, if not specified is hour.",
          "disabled": true
        }
      ]
    },
    "description": "Search for public Tweets created in the last 7 days.\n\nFor full details, see the [API reference](https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent) for this endpoint.\n\n[Sign up](https://t.co/signup) for the Twitter API"
  },
  "response": [
  ]
}