SQL Server / Twitter API v2 / User memberships
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://api.twitter.com/2/users/:id/list_memberships', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
EXEC sp_OAGetProperty @http, 'LastStatus', @iTmp0 OUT
PRINT 'Response status code = ' + @iTmp0
EXEC sp_OAMethod @sbResponseBody, 'GetAsString', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
END
GO
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://api.twitter.com/2/users/:id/list_memberships
Postman Collection Item JSON
{
"name": "User memberships",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "formdata",
"formdata": [
]
},
"url": {
"raw": "https://api.twitter.com/2/users/:id/list_memberships",
"protocol": "https",
"host": [
"api",
"twitter",
"com"
],
"path": [
"2",
"users",
":id",
"list_memberships"
],
"query": [
{
"key": "list.fields",
"value": "",
"description": "Comma-separated fields for the List object.\nAllowed values:\ncreated_at, follower_count, member_count, private, description, owner_id\nDefault values:\nid,name",
"disabled": true
},
{
"key": "user.fields",
"value": "",
"description": "Comma-separated list of fields for the User object.\nExpansion required.\nAllowed values:\ncreated_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld\nDefault values:\nid,name,username",
"disabled": true
},
{
"key": "expansions",
"value": "",
"description": "Expansions enable requests to expand an ID into a full object in the includes response object.\nAllowed value:\nowner_id\nDefault value: none",
"disabled": true
},
{
"key": "max_results",
"value": null,
"description": "The maximum number of results to be returned by a request.\nAllowed values: 1 through 100.\nDefault value: 100",
"disabled": true
},
{
"key": "pagination_token",
"value": null,
"description": "This parameter is used to get the next 'page' of results. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.",
"disabled": true
}
],
"variable": [
{
"key": "id",
"value": "",
"description": "Required. The ID of the user you wish to recieve membership details on."
}
]
},
"description": "This endpoint returns details on Lists a user is a member of specified by the requested ID\n\nFor full details, see the [API reference](https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/get-users-id-list_memberships) for this endpoint.\n\n[Sign up](https://t.co/signup) for the Twitter API"
},
"response": [
]
}