SYNCER

SYNCER

GET direct_messages/sent - 送信したDMを取得する

9件

公開日:

direct_messages/sent(GETメソッド)は、送信したダイレクトメッセージの内容を取得するためのエンドポイントです。

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

リソース

エンドポイント

GET https://api.twitter.com/1.1/direct_messages/sent.json

条件

項目ユーザー認証アプリケーション認証
利用×
パーミッションRead,Write and Access direct messages-
レートリミット15 / 15min-

パラメータ

since_id

指定例: 600501875784355800

ページングに利用する。ダイレクトメッセージのIDを指定すると、これを含まず、これより未来のダイレクトメッセージを取得できる。

max_id

指定例: 600501875784355800

ページングに利用する。ダイレクトメッセージのIDを指定すると、これを含まず、これより過去のダイレクトメッセージを取得できる。

count

指定例: 10

結果の数。1200の間で指定する。

page

指定例: 2

何ページ目を取得するか。

include_entities

指定例: true

ダイレクトメッセージオブジェクト内のentitiesプロパティを含めるか否か。

レスポンス

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

リクエストURL

https://api.twitter.com/1.1/direct_messages/sent.json?count=3&page=1&include_entities=true

リクエストヘッダー

Authorization: OAuth count=3,include_entities=true,oauth_consumer_key=:consumer_key,oauth_nonce=0.47852800+1484636128,oauth_signature_method=HMAC-SHA1,oauth_timestamp=1484636128,oauth_token=:access_token,oauth_version=1.0,page=1,oauth_signature=%2Fb7aak74UND2%2BGq5rTgoyK%2B1mBs%3D

レスポンスボディ (JSON)

JSON

[{"id":821248670515400707,"id_str":"821248670515400707","text":"\u3044\u3061\u306e\u3044\u3067\u4f1a\u9928\u3082\u904b\u8ee2\u304c\u5927\u5909\u3060\u3051\u3069\u826f\u3044\u3068\u3053\u308d\u3067\u3059\u3002","sender":{"id":2905085521,"id_str":"2905085521","name":"SYNCER","screen_name":"SyncerJP","location":"Tokyo","description":"\u30d6\u30ed\u30b0\u300cSYNCER\u300d\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u3059\u3002\u8a18\u4e8b\u306b\u8a00\u53ca\u3057\u3066\u304f\u308c\u305f\u30c4\u30a4\u30fc\u30c8\u3092\u304a\u6c17\u306b\u5165\u308a\u767b\u9332\u3057\u305f\u308a\u3057\u307e\u3059\u3002 \u6700\u7d42\u66f4\u65b0\u65e5:2015\/05\/22","url":"https:\/\/t.co\/J5bOOK7ugS","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/J5bOOK7ugS","expanded_url":"https:\/\/syncer.jp","display_url":"syncer.jp","indices":[0,23]}]},"description":{"urls":[]}},"protected":false,"followers_count":266,"friends_count":3,"listed_count":10,"created_at":"Thu Nov 20 11:17:51 +0000 2014","favourites_count":1621,"utc_offset":32400,"time_zone":"Tokyo","geo_enabled":true,"verified":false,"statuses_count":640,"lang":"ja","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"000000","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/600501255656448000\/1qe0CVbE.png","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/600501255656448000\/1qe0CVbE.png","profile_background_tile":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/604130129762074624\/5c0Rku36_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/604130129762074624\/5c0Rku36_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/2905085521\/1432005636","profile_link_color":"D36015","profile_sidebar_border_color":"C6E2EE","profile_sidebar_fill_color":"DAECF4","profile_text_color":"663B12","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false,"translator_type":"none"},"sender_id":2905085521,"sender_id_str":"2905085521","sender_screen_name":"SyncerJP","recipient":{"id":1528352858,"id_str":"1528352858","name":"\u3042\u3089\u3086","screen_name":"arayutw","location":"\u6771\u4eac\u90fd\u8db3\u7acb\u533a","description":"SYNCER\u3068\u3044\u3046\u30b5\u30a4\u30c8\u3092\u904b\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u63b2\u793a\u677f\u2192 https:\/\/t.co\/OAIDbACF3N","url":"https:\/\/t.co\/lW3GYq8sQl","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/lW3GYq8sQl","expanded_url":"https:\/\/syncer.jp\/","display_url":"syncer.jp","indices":[0,23]}]},"description":{"urls":[{"url":"https:\/\/t.co\/OAIDbACF3N","expanded_url":"https:\/\/forum.syncer.jp\/","display_url":"forum.syncer.jp","indices":[26,49]}]}},"protected":false,"followers_count":1418,"friends_count":564,"listed_count":113,"created_at":"Tue Jun 18 17:28:51 +0000 2013","favourites_count":4447,"utc_offset":32400,"time_zone":"Asia\/Tokyo","geo_enabled":true,"verified":false,"statuses_count":34792,"lang":"ja","contributors_enabled":false,"is_translator":false,"is_translation_enabled":true,"profile_background_color":"2660A1","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/632205394824183808\/FIL3S4z4.png","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/632205394824183808\/FIL3S4z4.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/631038167416619008\/7xfGAEwp_normal.png","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/631038167416619008\/7xfGAEwp_normal.png","profile_link_color":"D36015","profile_sidebar_border_color":"F2E195","profile_sidebar_fill_color":"FFF7CC","profile_text_color":"0C3E53","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false,"translator_type":"regular"},"recipient_id":1528352858,"recipient_id_str":"1528352858","recipient_screen_name":"arayutw","created_at":"Tue Jan 17 06:51:55 +0000 2017","entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[]}},{"id":821248555394314243,"id_str":"821248555394314243","text":"\u6e6f\u3051\u3080\u308a\u5c55\u671b\u53f0\u304b\u3089\u306e\u666f\u8272\u304c\u6700\u9ad8\u3067\u3059\u306d\ud83e\udd23","sender":{"id":2905085521,"id_str":"2905085521","name":"SYNCER","screen_name":"SyncerJP","location":"Tokyo","description":"\u30d6\u30ed\u30b0\u300cSYNCER\u300d\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u3059\u3002\u8a18\u4e8b\u306b\u8a00\u53ca\u3057\u3066\u304f\u308c\u305f\u30c4\u30a4\u30fc\u30c8\u3092\u304a\u6c17\u306b\u5165\u308a\u767b\u9332\u3057\u305f\u308a\u3057\u307e\u3059\u3002 \u6700\u7d42\u66f4\u65b0\u65e5:2015\/05\/22","url":"https:\/\/t.co\/J5bOOK7ugS","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/J5bOOK7ugS","expanded_url":"https:\/\/syncer.jp","display_url":"syncer.jp","indices":[0,23]}]},"description":{"urls":[]}},"protected":false,"followers_count":266,"friends_count":3,"listed_count":10,"created_at":"Thu Nov 20 11:17:51 +0000 2014","favourites_count":1621,"utc_offset":32400,"time_zone":"Tokyo","geo_enabled":true,"verified":false,"statuses_count":640,"lang":"ja","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"000000","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/600501255656448000\/1qe0CVbE.png","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/600501255656448000\/1qe0CVbE.png","profile_background_tile":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/604130129762074624\/5c0Rku36_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/604130129762074624\/5c0Rku36_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/2905085521\/1432005636","profile_link_color":"D36015","profile_sidebar_border_color":"C6E2EE","profile_sidebar_fill_color":"DAECF4","profile_text_color":"663B12","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false,"translator_type":"none"},"sender_id":2905085521,"sender_id_str":"2905085521","sender_screen_name":"SyncerJP","recipient":{"id":1528352858,"id_str":"1528352858","name":"\u3042\u3089\u3086","screen_name":"arayutw","location":"\u6771\u4eac\u90fd\u8db3\u7acb\u533a","description":"SYNCER\u3068\u3044\u3046\u30b5\u30a4\u30c8\u3092\u904b\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u63b2\u793a\u677f\u2192 https:\/\/t.co\/OAIDbACF3N","url":"https:\/\/t.co\/lW3GYq8sQl","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/lW3GYq8sQl","expanded_url":"https:\/\/syncer.jp\/","display_url":"syncer.jp","indices":[0,23]}]},"description":{"urls":[{"url":"https:\/\/t.co\/OAIDbACF3N","expanded_url":"https:\/\/forum.syncer.jp\/","display_url":"forum.syncer.jp","indices":[26,49]}]}},"protected":false,"followers_count":1418,"friends_count":564,"listed_count":113,"created_at":"Tue Jun 18 17:28:51 +0000 2013","favourites_count":4447,"utc_offset":32400,"time_zone":"Asia\/Tokyo","geo_enabled":true,"verified":false,"statuses_count":34792,"lang":"ja","contributors_enabled":false,"is_translator":false,"is_translation_enabled":true,"profile_background_color":"2660A1","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/632205394824183808\/FIL3S4z4.png","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/632205394824183808\/FIL3S4z4.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/631038167416619008\/7xfGAEwp_normal.png","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/631038167416619008\/7xfGAEwp_normal.png","profile_link_color":"D36015","profile_sidebar_border_color":"F2E195","profile_sidebar_fill_color":"FFF7CC","profile_text_color":"0C3E53","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false,"translator_type":"regular"},"recipient_id":1528352858,"recipient_id_str":"1528352858","recipient_screen_name":"arayutw","created_at":"Tue Jan 17 06:51:28 +0000 2017","entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[]}},{"id":821242752100802563,"id_str":"821242752100802563","text":"\u3053\u3093\u306b\u3061\u308f\u3093\u3053\u305d\u3070\ud83d\ude00","sender":{"id":2905085521,"id_str":"2905085521","name":"SYNCER","screen_name":"SyncerJP","location":"Tokyo","description":"\u30d6\u30ed\u30b0\u300cSYNCER\u300d\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u3059\u3002\u8a18\u4e8b\u306b\u8a00\u53ca\u3057\u3066\u304f\u308c\u305f\u30c4\u30a4\u30fc\u30c8\u3092\u304a\u6c17\u306b\u5165\u308a\u767b\u9332\u3057\u305f\u308a\u3057\u307e\u3059\u3002 \u6700\u7d42\u66f4\u65b0\u65e5:2015\/05\/22","url":"https:\/\/t.co\/J5bOOK7ugS","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/J5bOOK7ugS","expanded_url":"https:\/\/syncer.jp","display_url":"syncer.jp","indices":[0,23]}]},"description":{"urls":[]}},"protected":false,"followers_count":266,"friends_count":3,"listed_count":10,"created_at":"Thu Nov 20 11:17:51 +0000 2014","favourites_count":1621,"utc_offset":32400,"time_zone":"Tokyo","geo_enabled":true,"verified":false,"statuses_count":640,"lang":"ja","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"000000","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/600501255656448000\/1qe0CVbE.png","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/600501255656448000\/1qe0CVbE.png","profile_background_tile":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/604130129762074624\/5c0Rku36_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/604130129762074624\/5c0Rku36_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/2905085521\/1432005636","profile_link_color":"D36015","profile_sidebar_border_color":"C6E2EE","profile_sidebar_fill_color":"DAECF4","profile_text_color":"663B12","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false,"translator_type":"none"},"sender_id":2905085521,"sender_id_str":"2905085521","sender_screen_name":"SyncerJP","recipient":{"id":1528352858,"id_str":"1528352858","name":"\u3042\u3089\u3086","screen_name":"arayutw","location":"\u6771\u4eac\u90fd\u8db3\u7acb\u533a","description":"SYNCER\u3068\u3044\u3046\u30b5\u30a4\u30c8\u3092\u904b\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u63b2\u793a\u677f\u2192 https:\/\/t.co\/OAIDbACF3N","url":"https:\/\/t.co\/lW3GYq8sQl","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/lW3GYq8sQl","expanded_url":"https:\/\/syncer.jp\/","display_url":"syncer.jp","indices":[0,23]}]},"description":{"urls":[{"url":"https:\/\/t.co\/OAIDbACF3N","expanded_url":"https:\/\/forum.syncer.jp\/","display_url":"forum.syncer.jp","indices":[26,49]}]}},"protected":false,"followers_count":1418,"friends_count":564,"listed_count":113,"created_at":"Tue Jun 18 17:28:51 +0000 2013","favourites_count":4447,"utc_offset":32400,"time_zone":"Asia\/Tokyo","geo_enabled":true,"verified":false,"statuses_count":34792,"lang":"ja","contributors_enabled":false,"is_translator":false,"is_translation_enabled":true,"profile_background_color":"2660A1","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/632205394824183808\/FIL3S4z4.png","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/632205394824183808\/FIL3S4z4.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/631038167416619008\/7xfGAEwp_normal.png","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/631038167416619008\/7xfGAEwp_normal.png","profile_link_color":"D36015","profile_sidebar_border_color":"F2E195","profile_sidebar_fill_color":"FFF7CC","profile_text_color":"0C3E53","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false,"translator_type":"regular"},"recipient_id":1528352858,"recipient_id_str":"1528352858","recipient_screen_name":"arayutw","created_at":"Tue Jan 17 06:28:24 +0000 2017","entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[]}}]

レスポンスヘッダー

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: 12844
content-type: application/json;charset=utf-8
date: Tue, 17 Jan 2017 06:55:28 GMT
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Tue, 17 Jan 2017 06:55:28 GMT
pragma: no-cache
server: tsa_m
set-cookie: lang=ja; Path=/
set-cookie: guest_id=v1%3A148463612867936362; Domain=.twitter.com; Path=/; Expires=Thu, 17-Jan-2019 06:55:28 UTC
status: 200 OK
strict-transport-security: max-age=631138519
x-access-level: read-write-directmessages
x-connection-hash: 1cdaa82e4b357f8b0293f4e3d2b90a56
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-rate-limit-limit: 300
x-rate-limit-remaining: 299
x-rate-limit-reset: 1484637028
x-response-time: 175
x-transaction: 00856d4c00e08704
x-twitter-response-tags: BouncerCompliant
x-xss-protection: 1; mode=block

デモ

direct_messages/sentのリクエストを試すことができます。ユーザー認証のデモを試す場合は、アプリケーション(ダイレクトメッセージ権限)の連携を許可する必要があります。アクセス権限が強力なため、連携の解除を忘れないで下さい。連携を解除し忘れたとしても、当アプリケーションが許可なくデータにアクセスすることはありません。

since_id

max_id

count

page

include_entities

/

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

/

サンプルコード

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

アクセストークン

PHP (OAuth1.0)

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

	[GET direct_messages/sent]のお試しプログラム

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

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

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

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

	// パラメータA (オプション)
	$params_a = array(
//		"since_id" => "600501875784355800",
//		"max_id" => "600501875784355800",
//		"count" => "10",
//		"page" => "2",
//		"include_entities" => "true",
	) ;

	// キーを作成する (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 direct_messages/sent</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/direct_messages/sent/" target="_blank">SYNCER</a></small>' ;

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