Chilkat Online Tools

TCL / Twitter API v2 / Hide a reply

Back to Collection Items

load ./chilkat.dll

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

set http [new_CkHttp]

# Use this online tool to generate code from sample JSON: Generate Code to Create JSON

# The following JSON is sent in the request body.

# {
#   "hidden": true
# }

set json [new_CkJsonObject]

CkJsonObject_UpdateBool $json "hidden" 1

# Adds the "Authorization: Bearer <access_token>" header.
CkHttp_put_AuthToken $http "<access_token>"
CkHttp_SetRequestHeader $http "Content-Type" "application/json"

set sbRequestBody [new_CkStringBuilder]

CkJsonObject_EmitSb $json $sbRequestBody

# resp is a CkHttpResponse
set resp [CkHttp_PTextSb $http "PUT" "https://api.twitter.com/2/tweets/:id/hidden" $sbRequestBody "utf-8" "application/json" 0 0]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbRequestBody
    exit
}

puts [CkHttpResponse_get_StatusCode $resp]
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttpResponse $resp


delete_CkHttp $http
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody

Curl Command

curl -X PUT
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-d '{
    "hidden": true
}'
https://api.twitter.com/2/tweets/:id/hidden

Postman Collection Item JSON

{
  "name": "Hide a reply",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"hidden\": true\n}"
    },
    "url": {
      "raw": "https://api.twitter.com/2/tweets/:id/hidden",
      "protocol": "https",
      "host": [
        "api",
        "twitter",
        "com"
      ],
      "path": [
        "2",
        "tweets",
        ":id",
        "hidden"
      ],
      "variable": [
        {
          "key": "id",
          "value": "",
          "type": "string",
          "description": "Required. Enter a single Tweet ID."
        }
      ]
    },
    "description": "Provides the ability to hide a reply to a Tweet.\n\nFor full details, see the [API reference](https://developer.twitter.com/en/docs/twitter-api/tweets/hide-replies/api-reference/put-tweets-id-hidden) for this endpoint.\n\n[Sign up](https://t.co/signup) for the Twitter API"
  },
  "response": [
  ]
}