SYNCER

SYNCER

GET collections/entries - コレクションをタイムライン付きで取得する

9件

公開日:

collections/entries(GETメソッド)は、指定したコレクションを取得するエンドポイントです。結果にはタイムラインが含まれます。sort_indexというデータを利用してページングができます。

GET collections/entries
GET collections/entries
Twitterの公式リファレンス(英語)。collections/entriesに関する説明があります。

リソース

エンドポイント

GET https://api.twitter.com/1.1/collections/entries.json

条件

項目ユーザー認証アプリケーション認証
利用×
パーミッションRead-
レートリミット1000 / 15min-

パラメータ

id

指定例: custom-539487832448843776

対象のコレクションID。

count

指定例: 10

結果に含めるツイートの数。

max_position

指定例: 378805531336272896

ページングに利用する。位置を表すsort_indexの番号を指定すると、このツイートを含まずに、これより過去のツイートだけを取得できる。sort_indexの番号は、コレクションのタイムラインを取得した時のsort_indexプロパティに含まれている。

min_position

指定例: 378805531336272896

ページングに利用する。位置を表すsort_indexの番号を指定すると、このツイートを含まずに、これより未来のツイートだけを取得できる。sort_indexの番号は、コレクションのタイムラインを取得した時のsort_indexプロパティに含まれている。

レスポンス

アクセストークン(OAuth1.0)でリクエストをした場合の例です。

リクエストURL

https://api.twitter.com/1.1/collections/entries.json?id=custom-539487832448843776

リクエストヘッダー

Authorization: OAuth id=custom-539487832448843776,oauth_consumer_key=:consumer_key,oauth_nonce=0.45455200+1484631266,oauth_signature_method=HMAC-SHA1,oauth_timestamp=1484631266,oauth_token=:access_token,oauth_version=1.0,oauth_signature=7jaO6zC9ojKKNMEoz6SLQIn%2FzYM%3D

レスポンスボディ (JSON)

JSON

{"objects":{"tweets":{"532654992071852032":{"created_at":"Wed Nov 12 22:03:41 +0000 2014","id":532654992071852032,"id_str":"532654992071852032","text":"If you like night sky photos, you'll love this pic of the Milky Way over Devils Tower National Monument by David Lane http:\/\/t.co\/zt8tHTw2cU","truncated":false,"entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[],"media":[{"id":532654988409835520,"id_str":"532654988409835520","indices":[118,140],"media_url":"http:\/\/pbs.twimg.com\/media\/B2Re48wCEAAeY5m.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/B2Re48wCEAAeY5m.jpg","url":"http:\/\/t.co\/zt8tHTw2cU","display_url":"pic.twitter.com\/zt8tHTw2cU","expanded_url":"https:\/\/twitter.com\/Interior\/status\/532654992071852032\/photo\/1","type":"photo","sizes":{"small":{"w":340,"h":227,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":600,"h":400,"resize":"fit"},"large":{"w":1024,"h":683,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":532654988409835520,"id_str":"532654988409835520","indices":[118,140],"media_url":"http:\/\/pbs.twimg.com\/media\/B2Re48wCEAAeY5m.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/B2Re48wCEAAeY5m.jpg","url":"http:\/\/t.co\/zt8tHTw2cU","display_url":"pic.twitter.com\/zt8tHTw2cU","expanded_url":"https:\/\/twitter.com\/Interior\/status\/532654992071852032\/photo\/1","type":"photo","sizes":{"small":{"w":340,"h":227,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":600,"h":400,"resize":"fit"},"large":{"w":1024,"h":683,"resize":"fit"}}}]},"source":"\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":76348185,"id_str":"76348185"},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":1305,"favorite_count":2148,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"653229520015749121":{"created_at":"Sun Oct 11 15:23:48 +0000 2015","id":653229520015749121,"id_str":"653229520015749121","text":"Fall @GrandTetonNPS looks something like this: Beautiful! Pic by Ed Cooper #Wyoming http:\/\/t.co\/29HJQma7Jp","truncated":false,"entities":{"hashtags":[{"text":"Wyoming","indices":[75,83]}],"symbols":[],"user_mentions":[{"screen_name":"GrandTetonNPS","name":"Grand Teton NP","id":44991932,"id_str":"44991932","indices":[5,19]}],"urls":[],"media":[{"id":653229513694912513,"id_str":"653229513694912513","indices":[84,106],"media_url":"http:\/\/pbs.twimg.com\/media\/CRC8yCCWIAEHy0R.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/CRC8yCCWIAEHy0R.jpg","url":"http:\/\/t.co\/29HJQma7Jp","display_url":"pic.twitter.com\/29HJQma7Jp","expanded_url":"https:\/\/twitter.com\/Interior\/status\/653229520015749121\/photo\/1","type":"photo","sizes":{"large":{"w":1008,"h":795,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":600,"h":473,"resize":"fit"},"small":{"w":340,"h":268,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":653229513694912513,"id_str":"653229513694912513","indices":[84,106],"media_url":"http:\/\/pbs.twimg.com\/media\/CRC8yCCWIAEHy0R.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/CRC8yCCWIAEHy0R.jpg","url":"http:\/\/t.co\/29HJQma7Jp","display_url":"pic.twitter.com\/29HJQma7Jp","expanded_url":"https:\/\/twitter.com\/Interior\/status\/653229520015749121\/photo\/1","type":"photo","sizes":{"large":{"w":1008,"h":795,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":600,"h":473,"resize":"fit"},"small":{"w":340,"h":268,"resize":"fit"}}}]},"source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":76348185,"id_str":"76348185"},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":790,"favorite_count":1693,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"651780213496545280":{"created_at":"Wed Oct 07 15:24:47 +0000 2015","id":651780213496545280,"id_str":"651780213496545280","text":"Fall foliage & snow-capped peaks: Isn't @DenaliNPS spectacular? Pic by Michel Hersen #Alaska http:\/\/t.co\/LOTJsl6iK1","truncated":false,"entities":{"hashtags":[{"text":"Alaska","indices":[89,96]}],"symbols":[],"user_mentions":[{"screen_name":"DenaliNPS","name":"Denali National Park","id":45943457,"id_str":"45943457","indices":[44,54]}],"urls":[],"media":[{"id":651780212187795456,"id_str":"651780212187795456","indices":[97,119],"media_url":"http:\/\/pbs.twimg.com\/media\/CQuWplMVEAAzFBC.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/CQuWplMVEAAzFBC.jpg","url":"http:\/\/t.co\/LOTJsl6iK1","display_url":"pic.twitter.com\/LOTJsl6iK1","expanded_url":"https:\/\/twitter.com\/Interior\/status\/651780213496545280\/photo\/1","type":"photo","sizes":{"medium":{"w":600,"h":398,"resize":"fit"},"small":{"w":340,"h":226,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":1024,"h":680,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":651780212187795456,"id_str":"651780212187795456","indices":[97,119],"media_url":"http:\/\/pbs.twimg.com\/media\/CQuWplMVEAAzFBC.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/CQuWplMVEAAzFBC.jpg","url":"http:\/\/t.co\/LOTJsl6iK1","display_url":"pic.twitter.com\/LOTJsl6iK1","expanded_url":"https:\/\/twitter.com\/Interior\/status\/651780213496545280\/photo\/1","type":"photo","sizes":{"medium":{"w":600,"h":398,"resize":"fit"},"small":{"w":340,"h":226,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":1024,"h":680,"resize":"fit"}}}]},"source":"\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":76348185,"id_str":"76348185"},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":599,"favorite_count":1774,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"652174303283277825":{"created_at":"Thu Oct 08 17:30:45 +0000 2015","id":652174303283277825,"id_str":"652174303283277825","text":"Relax & read this #BearCam story from @Buzzfeed (you won't regret it): http:\/\/t.co\/ZFqP1kVz91 #SeeTheMomentWhen \ud83d\udc3b https:\/\/t.co\/O9HxdEj2HD","truncated":false,"entities":{"hashtags":[{"text":"BearCam","indices":[22,30]},{"text":"SeeTheMomentWhen","indices":[98,115]}],"symbols":[],"user_mentions":[{"screen_name":"BuzzFeed","name":"BuzzFeed","id":5695632,"id_str":"5695632","indices":[42,51]}],"urls":[{"url":"http:\/\/t.co\/ZFqP1kVz91","expanded_url":"http:\/\/on.doi.gov\/1LoDB3u","display_url":"on.doi.gov\/1LoDB3u","indices":[75,97]},{"url":"https:\/\/t.co\/O9HxdEj2HD","expanded_url":"https:\/\/vine.co\/v\/ertTMU2PMzb","display_url":"vine.co\/v\/ertTMU2PMzb","indices":[118,141]}]},"source":"\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":76348185,"id_str":"76348185"},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":740,"favorite_count":3503,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"524573263163572224":{"created_at":"Tue Oct 21 14:49:46 +0000 2014","id":524573263163572224,"id_str":"524573263163572224","text":"A gorgeous #sunrise after a fresh coat of snow @GrandTetonNPS by Robert Buman #Wyoming http:\/\/t.co\/ODxB4Jdf0h","truncated":false,"entities":{"hashtags":[{"text":"sunrise","indices":[11,19]},{"text":"Wyoming","indices":[78,86]}],"symbols":[],"user_mentions":[{"screen_name":"GrandTetonNPS","name":"Grand Teton NP","id":44991932,"id_str":"44991932","indices":[47,61]}],"urls":[],"media":[{"id":524573259606409217,"id_str":"524573259606409217","indices":[87,109],"media_url":"http:\/\/pbs.twimg.com\/media\/B0eoma2CQAETgA_.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/B0eoma2CQAETgA_.jpg","url":"http:\/\/t.co\/ODxB4Jdf0h","display_url":"pic.twitter.com\/ODxB4Jdf0h","expanded_url":"https:\/\/twitter.com\/Interior\/status\/524573263163572224\/photo\/1","type":"photo","sizes":{"small":{"w":340,"h":227,"resize":"fit"},"large":{"w":1024,"h":683,"resize":"fit"},"medium":{"w":600,"h":400,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"}}}]},"extended_entities":{"media":[{"id":524573259606409217,"id_str":"524573259606409217","indices":[87,109],"media_url":"http:\/\/pbs.twimg.com\/media\/B0eoma2CQAETgA_.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/B0eoma2CQAETgA_.jpg","url":"http:\/\/t.co\/ODxB4Jdf0h","display_url":"pic.twitter.com\/ODxB4Jdf0h","expanded_url":"https:\/\/twitter.com\/Interior\/status\/524573263163572224\/photo\/1","type":"photo","sizes":{"small":{"w":340,"h":227,"resize":"fit"},"large":{"w":1024,"h":683,"resize":"fit"},"medium":{"w":600,"h":400,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"}}}]},"source":"\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":76348185,"id_str":"76348185"},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":853,"favorite_count":1681,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"504032379045179393":{"created_at":"Mon Aug 25 22:27:38 +0000 2014","id":504032379045179393,"id_str":"504032379045179393","text":"How about a grizzly bear waving for the camera @LakeClarkNPS to end the day? Photo: Kevin Dietrich http:\/\/t.co\/HtdvV0bPEu","truncated":false,"entities":{"hashtags":[],"symbols":[],"user_mentions":[{"screen_name":"LakeClarkNPS","name":"Lake Clark NP&P","id":66453289,"id_str":"66453289","indices":[47,60]}],"urls":[],"media":[{"id":504032378411446273,"id_str":"504032378411446273","indices":[99,121],"media_url":"http:\/\/pbs.twimg.com\/media\/Bv6uxxaCcAEjWHD.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/Bv6uxxaCcAEjWHD.jpg","url":"http:\/\/t.co\/HtdvV0bPEu","display_url":"pic.twitter.com\/HtdvV0bPEu","expanded_url":"https:\/\/twitter.com\/Interior\/status\/504032379045179393\/photo\/1","type":"photo","sizes":{"small":{"w":340,"h":231,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":600,"h":407,"resize":"fit"},"large":{"w":1024,"h":695,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":504032378411446273,"id_str":"504032378411446273","indices":[99,121],"media_url":"http:\/\/pbs.twimg.com\/media\/Bv6uxxaCcAEjWHD.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/Bv6uxxaCcAEjWHD.jpg","url":"http:\/\/t.co\/HtdvV0bPEu","display_url":"pic.twitter.com\/HtdvV0bPEu","expanded_url":"https:\/\/twitter.com\/Interior\/status\/504032379045179393\/photo\/1","type":"photo","sizes":{"small":{"w":340,"h":231,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":600,"h":407,"resize":"fit"},"large":{"w":1024,"h":695,"resize":"fit"}}}]},"source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":76348185,"id_str":"76348185"},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":806,"favorite_count":1583,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"}},"users":{"76348185":{"id":76348185,"id_str":"76348185","name":"US Dept of Interior","screen_name":"Interior","location":"Washington, DC","description":"Protecting America\u2019s Great Outdoors and Powering Our Future","url":"http:\/\/t.co\/gUty7d4LZ8","entities":{"url":{"urls":[{"url":"http:\/\/t.co\/gUty7d4LZ8","expanded_url":"http:\/\/www.doi.gov","display_url":"doi.gov","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":2160962,"friends_count":235264,"listed_count":6764,"created_at":"Tue Sep 22 14:36:29 +0000 2009","favourites_count":2486,"utc_offset":-18000,"time_zone":"Eastern Time (US & Canada)","geo_enabled":true,"verified":true,"statuses_count":14821,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C6E2EE","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/688410897\/0390727e0b833fa7f8536a100da185fa.jpeg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/688410897\/0390727e0b833fa7f8536a100da185fa.jpeg","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/432081479\/DOI_LOGO_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/432081479\/DOI_LOGO_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/76348185\/1483469242","profile_link_color":"1F98C7","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DAECF4","profile_text_color":"050505","profile_use_background_image":true,"has_extended_profile":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false,"translator_type":"none"},"2244994945":{"id":2244994945,"id_str":"2244994945","name":"TwitterDev","screen_name":"TwitterDev","location":"Internet","description":"Your official source for Twitter Platform news, updates & events. Need technical help? Visit https:\/\/t.co\/mGHnxZCxkt \u2328\ufe0f #TapIntoTwitter","url":"https:\/\/t.co\/66w26cua1O","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/66w26cua1O","expanded_url":"https:\/\/dev.twitter.com\/","display_url":"dev.twitter.com","indices":[0,23]}]},"description":{"urls":[{"url":"https:\/\/t.co\/mGHnxZCxkt","expanded_url":"https:\/\/twittercommunity.com\/","display_url":"twittercommunity.com","indices":[93,116]}]}},"protected":false,"followers_count":451550,"friends_count":1530,"listed_count":1099,"created_at":"Sat Dec 14 04:35:55 +0000 2013","favourites_count":1949,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":true,"statuses_count":2899,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"FFFFFF","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/530814764687949824\/npQQVkq8_normal.png","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/530814764687949824\/npQQVkq8_normal.png","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/2244994945\/1396995246","profile_link_color":"0084B4","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false,"translator_type":"regular"}},"timelines":{"custom-539487832448843776":{"name":"National Park Tweets","user_id":"2244994945","collection_url":"https:\/\/twitter.com\/TwitterDev\/timelines\/539487832448843776","custom_timeline_url":"https:\/\/twitter.com\/TwitterDev\/timelines\/539487832448843776","description":"A collection of Tweets about National Parks in the United States.","url":"","visibility":"public","timeline_order":"curation_reverse_chron","collection_type":"user","custom_timeline_type":"user"}}},"response":{"timeline":[{"tweet":{"id":"652174303283277825","sort_index":"378805531336272896"},"feature_context":"HBgGY3VzdG9tFoCAktzo1NL8DgAA"},{"tweet":{"id":"651780213496545280","sort_index":"378805461464858624"},"feature_context":"HBgGY3VzdG9tFoCAktzo1NL8DgAA"},{"tweet":{"id":"653229520015749121","sort_index":"378805449492181504"},"feature_context":"HBgGY3VzdG9tFoCAktzo1NL8DgAA"},{"tweet":{"id":"504032379045179393","sort_index":"371578415352947200"},"feature_context":"HBgGY3VzdG9tFoCAktzo1NL8DgAA"},{"tweet":{"id":"532654992071852032","sort_index":"371578393139797760"},"feature_context":"HBgGY3VzdG9tFoCAktzo1NL8DgAA"},{"tweet":{"id":"524573263163572224","sort_index":"371578380871797248"},"feature_context":"HBgGY3VzdG9tFoCAktzo1NL8DgAA"}],"timeline_id":"custom-539487832448843776","position":{"max_position":"378805531336272896","min_position":"371578380871797248","was_truncated":false}}}

レスポンスヘッダー

HTTP/1.1 200 OK
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-disposition: attachment; filename=json.json
content-length: 17169
content-type: application/json;charset=utf-8
date: Tue, 17 Jan 2017 05:34:26 GMT
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Tue, 17 Jan 2017 05:34:26 GMT
pragma: no-cache
server: tsa_m
set-cookie: lang=ja; Path=/
set-cookie: guest_id=v1%3A148463126660205929; Domain=.twitter.com; Path=/; Expires=Thu, 17-Jan-2019 05:34:26 UTC
status: 200 OK
strict-transport-security: max-age=631138519
x-access-level: read
x-connection-hash: 2f577cafe4cfe7e3d80b57b7c34d8779
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-rate-limit-limit: 1000
x-rate-limit-remaining: 993
x-rate-limit-reset: 1484631355
x-response-time: 172
x-transaction: 00acbfbb005939ac
x-twitter-response-tags: BouncerCompliant
x-xss-protection: 1; mode=block

デモ

collections/entriesのリクエストを試すことができます。ユーザー認証のデモを試す場合は、アプリケーション(読取権限)の連携を許可する必要があります。利用後、お手数ですが連携の解除をお願いします。連携を解除し忘れたとしても、当アプリケーションが許可なくデータにアクセスすることはありません。

id

count

max_position

min_position

認証方法 (ユーザー認証のみ)

/

サンプルコード

collections/entriesのエンドポイントを利用するためのサンプルプログラムです。各種トークンの情報をセットしてからPHPで起動して下さい。リクエストに成功すると、$jsonという変数に目的のデータが代入されます。このデータを整形するなり保存するなり、活用して下さい。

アクセストークン

PHP (OAuth1.0)

<?php
/**************************************************

	[GET collections/entries]のお試しプログラム

	認証方式: アクセストークン

	配布: SYNCER
	公式ドキュメント: https://dev.twitter.com/rest/reference/get/collections/entries
	日本語解説ページ: https://syncer.jp/Web/API/Twitter/REST_API/GET/collections/entries/

**************************************************/

	// 設定
	$api_key = '' ;		// APIキー
	$api_secret = '' ;		// APIシークレット
	$access_token = '' ;		// アクセストークン
	$access_token_secret = '' ;		// アクセストークンシークレット
	$request_url = 'https://api.twitter.com/1.1/collections/entries.json' ;		// エンドポイント
	$request_method = 'GET' ;

	// パラメータA (オプション)
	$params_a = array(
		"id" => "custom-539487832448843776",
//		"count" => "10",
//		"max_position" => "378805531336272896",
//		"min_position" => "378805531336272896",
	) ;

	// キーを作成する (URLエンコードする)
	$signature_key = rawurlencode( $api_secret ) . '&' . rawurlencode( $access_token_secret ) ;

	// パラメータB (署名の材料用)
	$params_b = array(
		'oauth_token' => $access_token ,
		'oauth_consumer_key' => $api_key ,
		'oauth_signature_method' => 'HMAC-SHA1' ,
		'oauth_timestamp' => time() ,
		'oauth_nonce' => microtime() ,
		'oauth_version' => '1.0' ,
	) ;

	// パラメータAとパラメータBを合成してパラメータCを作る
	$params_c = array_merge( $params_a , $params_b ) ;

	// 連想配列をアルファベット順に並び替える
	ksort( $params_c ) ;

	// パラメータの連想配列を[キー=値&キー=値...]の文字列に変換する
	$request_params = http_build_query( $params_c , '' , '&' ) ;

	// 一部の文字列をフォロー
	$request_params = str_replace( array( '+' , '%7E' ) , array( '%20' , '~' ) , $request_params ) ;

	// 変換した文字列をURLエンコードする
	$request_params = rawurlencode( $request_params ) ;

	// リクエストメソッドをURLエンコードする
	// ここでは、URL末尾の[?]以下は付けないこと
	$encoded_request_method = rawurlencode( $request_method ) ;
 
	// リクエストURLをURLエンコードする
	$encoded_request_url = rawurlencode( $request_url ) ;
 
	// リクエストメソッド、リクエストURL、パラメータを[&]で繋ぐ
	$signature_data = $encoded_request_method . '&' . $encoded_request_url . '&' . $request_params ;

	// キー[$signature_key]とデータ[$signature_data]を利用して、HMAC-SHA1方式のハッシュ値に変換する
	$hash = hash_hmac( 'sha1' , $signature_data , $signature_key , TRUE ) ;

	// base64エンコードして、署名[$signature]が完成する
	$signature = base64_encode( $hash ) ;

	// パラメータの連想配列、[$params]に、作成した署名を加える
	$params_c['oauth_signature'] = $signature ;

	// パラメータの連想配列を[キー=値,キー=値,...]の文字列に変換する
	$header_params = http_build_query( $params_c , '' , ',' ) ;

	// リクエスト用のコンテキスト
	$context = array(
		'http' => array(
			'method' => $request_method , // リクエストメソッド
			'header' => array(			  // ヘッダー
				'Authorization: OAuth ' . $header_params ,
			) ,
		) ,
	) ;

	// パラメータがある場合、URLの末尾に追加
	if( $params_a ) {
		$request_url .= '?' . http_build_query( $params_a ) ;
	}

	// オプションがある場合、コンテキストにPOSTフィールドを作成する (GETの場合は不要)
//	if( $params_a ) {
//		$context['http']['content'] = http_build_query( $params_a ) ;
//	}

	// cURLを使ってリクエスト
	$curl = curl_init() ;
	curl_setopt( $curl, CURLOPT_URL , $request_url ) ;
	curl_setopt( $curl, CURLOPT_HEADER, 1 ) ; 
	curl_setopt( $curl, CURLOPT_CUSTOMREQUEST , $context['http']['method'] ) ;	// メソッド
	curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER , false ) ;	// 証明書の検証を行わない
	curl_setopt( $curl, CURLOPT_RETURNTRANSFER , true ) ;	// curl_execの結果を文字列で返す
	curl_setopt( $curl, CURLOPT_HTTPHEADER , $context['http']['header'] ) ;	// ヘッダー
//	if( isset( $context['http']['content'] ) && !empty( $context['http']['content'] ) ) {		// GETの場合は不要
//		curl_setopt( $curl , CURLOPT_POSTFIELDS , $context['http']['content'] ) ;	// リクエストボディ
//	}
	curl_setopt( $curl , CURLOPT_TIMEOUT , 5 ) ;	// タイムアウトの秒数
	$res1 = curl_exec( $curl ) ;
	$res2 = curl_getinfo( $curl ) ;
	curl_close( $curl ) ;

	// 取得したデータ
	$json = substr( $res1, $res2['header_size'] ) ;		// 取得したデータ(JSONなど)
	$header = substr( $res1, 0, $res2['header_size'] ) ;	// レスポンスヘッダー (検証に利用したい場合にどうぞ)

	// [cURL]ではなく、[file_get_contents()]を使うには下記の通りです…
	// $json = file_get_contents( $request_url , false , stream_context_create( $context ) ) ;

	// JSONをオブジェクトに変換
	$obj = json_decode( $json ) ;

	// HTML用
	$html = '' ;

	// タイトル
	$html .= '<h1 style="text-align:center; border-bottom:1px solid #555; padding-bottom:12px; margin-bottom:48px; color:#D36015;">GET collections/entries</h1>' ;

	// エラー判定
	if( !$json || !$obj ) {
		$html .= '<h2>エラー内容</h2>' ;
		$html .= '<p>データを取得することができませんでした…。設定を見直して下さい。</p>' ;
	}

	// 検証用
	$html .= '<h2>取得したデータ</h2>' ;
	$html .= '<p>下記のデータを取得できました。</p>' ;
	$html .= 	'<h3>ボディ(JSON)</h3>' ;
	$html .= 	'<p><textarea style="width:80%" rows="8">' . $json . '</textarea></p>' ;
	$html .= 	'<h3>レスポンスヘッダー</h3>' ;
	$html .= 	'<p><textarea style="width:80%" rows="8">' . $header . '</textarea></p>' ;

	// 検証用
	$html .= '<h2>リクエストしたデータ</h2>' ;
	$html .= '<p>下記内容でリクエストをしました。</p>' ;
	$html .= 	'<h3>URL</h3>' ;
	$html .= 	'<p><textarea style="width:80%" rows="8">' . $context['http']['method'] . ' ' . $request_url . '</textarea></p>' ;
	$html .= 	'<h3>ヘッダー</h3>' ;
	$html .= 	'<p><textarea style="width:80%" rows="8">' . implode( "\r\n" , $context['http']['header'] ) . '</textarea></p>' ;

	// フッター
	$html .= '<small style="display:block; border-top:1px solid #555; padding-top:12px; margin-top:72px; text-align:center; font-weight:700;">プログラムの説明: <a href="https://syncer.jp/Web/API/Twitter/REST_API/GET/collections/entries/" target="_blank">SYNCER</a></small>' ;

	// 出力 (本稼働時はHTMLのヘッダー、フッターを付けよう)
	echo $html ;