SYNCER

SYNCER

Entity Object(エンティティオブジェクト)の説明

4件

公開日:

エンティティオブジェクトは、ユーザーオブジェクトやツイートオブジェクト、ダイレクトメッセージオブジェクトなどに含まれます。エンティティには「エンティティ(entities)」「拡張エンティティ(extended_entities)」の2種類があります。エンティティはテキストに含まれているURLアドレスやハッシュタグにリンクを付けてリッチテキスト化するための情報です。拡張エンティティはテキストに画像や動画を加えるための情報です。

JSONの例

ユーザーオブジェクト

ユーザーオブジェクトに含まれているエンティティ(entities)の例です。

JSON

{"id":1528352858,"id_str":"1528352858","name":"\u3042\u3089\u3086","screen_name":"arayutw","location":"Tokyo-to, Japan","profile_location":{"id":"a56612250c754f23","url":"https:\/\/api.twitter.com\/1.1\/geo\/id\/a56612250c754f23.json","place_type":"unknown","name":"Tokyo-to, Japan","full_name":"Tokyo-to, Japan","country_code":"","country":"","contained_within":[],"bounding_box":null,"attributes":{}},"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":1425,"friends_count":565,"listed_count":113,"created_at":"Tue Jun 18 17:28:51 +0000 2013","favourites_count":4464,"utc_offset":32400,"time_zone":"Asia\/Tokyo","geo_enabled":true,"verified":false,"statuses_count":35314,"lang":"ja","status":{"created_at":"Mon Jan 30 02:20:19 +0000 2017","id":825891362738311170,"id_str":"825891362738311170","text":"\u4eca\u65e5\u306f\u826f\u3044\u5929\u6c17\u3060\u3002","truncated":false,"entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[]},"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,"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"favorited":false,"retweeted":false,"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\/821911941396328448\/VjorK4J1.jpg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/821911941396328448\/VjorK4J1.jpg","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/821941553774010370\/5M2umxbl_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/821941553774010370\/5M2umxbl_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/1528352858\/1484800383","profile_link_color":"D36015","profile_sidebar_border_color":"F2E195","profile_sidebar_fill_color":"FFF7CC","profile_text_color":"0C3E53","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null,"translator_type":"regular"}

ツイートオブジェクト

ツイートオブジェクトに含まれているエンティティ(entities)と拡張エンティティ(extended_entities)の例です。ハッシュタグ、シンボルタグ、メンション、URL、メディアファイル(画像)のエンティティが含まれています。

JSON

{"created_at":"Sun Jan 29 08:56:00 +0000 2017","id":825628550799593473,"id_str":"825628550799593473","text":"\u3053\u308c\u306f\u3001\u30c4\u30a4\u30fc\u30c8\u3067\u3059\u3002\n\nhttps:\/\/t.co\/DZGyOVnHYM\n#\u30cf\u30c3\u30b7\u30e5\u30bf\u30b0\n$Symbol\n@Twitter https:\/\/t.co\/MN6CSArGuF","truncated":false,"entities":{"hashtags":[{"text":"\u30cf\u30c3\u30b7\u30e5\u30bf\u30b0","indices":[37,44]}],"symbols":[{"text":"Symbol","indices":[45,52]}],"user_mentions":[{"screen_name":"Twitter","name":"Twitter","id":783214,"id_str":"783214","indices":[53,61]}],"urls":[{"url":"https:\/\/t.co\/DZGyOVnHYM","expanded_url":"https:\/\/syncer.jp","display_url":"syncer.jp","indices":[13,36]}],"media":[{"id":825628201758052352,"id_str":"825628201758052352","indices":[62,85],"media_url":"http:\/\/pbs.twimg.com\/media\/C3U4eaJVUAAC50R.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/C3U4eaJVUAAC50R.jpg","url":"https:\/\/t.co\/MN6CSArGuF","display_url":"pic.twitter.com\/MN6CSArGuF","expanded_url":"https:\/\/twitter.com\/arayutw\/status\/825628550799593473\/photo\/1","type":"photo","sizes":{"small":{"w":400,"h":225,"resize":"fit"},"large":{"w":400,"h":225,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":400,"h":225,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":825628201758052352,"id_str":"825628201758052352","indices":[62,85],"media_url":"http:\/\/pbs.twimg.com\/media\/C3U4eaJVUAAC50R.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/C3U4eaJVUAAC50R.jpg","url":"https:\/\/t.co\/MN6CSArGuF","display_url":"pic.twitter.com\/MN6CSArGuF","expanded_url":"https:\/\/twitter.com\/arayutw\/status\/825628550799593473\/photo\/1","type":"photo","sizes":{"small":{"w":400,"h":225,"resize":"fit"},"large":{"w":400,"h":225,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":400,"h":225,"resize":"fit"}}},{"id":825628250898460672,"id_str":"825628250898460672","indices":[62,85],"media_url":"http:\/\/pbs.twimg.com\/media\/C3U4hRNUcAApOu_.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/C3U4hRNUcAApOu_.jpg","url":"https:\/\/t.co\/MN6CSArGuF","display_url":"pic.twitter.com\/MN6CSArGuF","expanded_url":"https:\/\/twitter.com\/arayutw\/status\/825628550799593473\/photo\/1","type":"photo","sizes":{"small":{"w":400,"h":225,"resize":"fit"},"large":{"w":400,"h":225,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":400,"h":225,"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":1528352858,"id_str":"1528352858","name":"\u3042\u3089\u3086","screen_name":"arayutw","location":"\u65e5\u672c \u6771\u4eac","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":1425,"friends_count":565,"listed_count":113,"created_at":"Tue Jun 18 17:28:51 +0000 2013","favourites_count":4464,"utc_offset":32400,"time_zone":"Asia\/Tokyo","geo_enabled":true,"verified":false,"statuses_count":35313,"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\/821911941396328448\/VjorK4J1.jpg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/821911941396328448\/VjorK4J1.jpg","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/821941553774010370\/5M2umxbl_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/821941553774010370\/5M2umxbl_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/1528352858\/1484800383","profile_link_color":"D36015","profile_sidebar_border_color":"F2E195","profile_sidebar_fill_color":"FFF7CC","profile_text_color":"0C3E53","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null,"translator_type":"regular"},"geo":null,"coordinates":null,"place":{"id":"06ef846bfc783874","url":"https:\/\/api.twitter.com\/1.1\/geo\/id\/06ef846bfc783874.json","place_type":"country","name":"Japan","full_name":"Japan","country_code":"JP","country":"Japan","contained_within":[],"bounding_box":{"type":"Polygon","coordinates":[[[122.9040343,24.0133434],[153.9976966,24.0133434],[153.9976966,45.562897],[122.9040343,45.562897]]]},"attributes":{}},"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":1,"favorited":false,"retweeted":false,"possibly_sensitive":false,"possibly_sensitive_appealable":false,"lang":"ja"}

ツイートオブジェクト (動画)

動画ファイルを含むツイートオブジェクトのエンティティ(entities)と拡張エンティティ(extended_entities)の例です。メディアファイルは、エンティティの方ではサムネイル画像扱いになっています。

JSON

{"created_at":"Sun Jan 29 03:22:45 +0000 2017","id":825544686550945793,"id_str":"825544686550945793","text":"API\u3092\u5229\u7528\u3057\u3066\u30c4\u30a4\u30fc\u30c8\u3092\u6295\u7a3f\u3057\u307e\u3057\u305f\u3002\u3053\u306e\u6295\u7a3f\u306f\u524a\u9664\u4e88\u5b9a\u3067\u3059\u3002 https:\/\/t.co\/iMGkgAtrKD","truncated":false,"entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[],"media":[{"id":825544677654880256,"id_str":"825544677654880256","indices":[33,56],"media_url":"http:\/\/pbs.twimg.com\/ext_tw_video_thumb\/825544677654880256\/pu\/img\/cFWk5zTX1uH_bGz-.jpg","media_url_https":"https:\/\/pbs.twimg.com\/ext_tw_video_thumb\/825544677654880256\/pu\/img\/cFWk5zTX1uH_bGz-.jpg","url":"https:\/\/t.co\/iMGkgAtrKD","display_url":"pic.twitter.com\/iMGkgAtrKD","expanded_url":"https:\/\/twitter.com\/arayutw\/status\/825544686550945793\/video\/1","type":"photo","sizes":{"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":600,"h":338,"resize":"fit"},"small":{"w":340,"h":191,"resize":"fit"},"large":{"w":640,"h":360,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":825544677654880256,"id_str":"825544677654880256","indices":[33,56],"media_url":"http:\/\/pbs.twimg.com\/ext_tw_video_thumb\/825544677654880256\/pu\/img\/cFWk5zTX1uH_bGz-.jpg","media_url_https":"https:\/\/pbs.twimg.com\/ext_tw_video_thumb\/825544677654880256\/pu\/img\/cFWk5zTX1uH_bGz-.jpg","url":"https:\/\/t.co\/iMGkgAtrKD","display_url":"pic.twitter.com\/iMGkgAtrKD","expanded_url":"https:\/\/twitter.com\/arayutw\/status\/825544686550945793\/video\/1","type":"video","sizes":{"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":600,"h":338,"resize":"fit"},"small":{"w":340,"h":191,"resize":"fit"},"large":{"w":640,"h":360,"resize":"fit"}},"video_info":{"aspect_ratio":[16,9],"duration_millis":2831,"variants":[{"bitrate":832000,"content_type":"video\/mp4","url":"https:\/\/video.twimg.com\/ext_tw_video\/825544677654880256\/pu\/vid\/640x360\/SoHOdxylks_azB-g.mp4"},{"content_type":"application\/dash+xml","url":"https:\/\/video.twimg.com\/ext_tw_video\/825544677654880256\/pu\/pl\/X8XyGM_DfTxqzetk.mpd"},{"content_type":"application\/x-mpegURL","url":"https:\/\/video.twimg.com\/ext_tw_video\/825544677654880256\/pu\/pl\/X8XyGM_DfTxqzetk.m3u8"},{"bitrate":320000,"content_type":"video\/mp4","url":"https:\/\/video.twimg.com\/ext_tw_video\/825544677654880256\/pu\/vid\/320x180\/EWtJBCKXPjyVsD1A.mp4"}]},"additional_media_info":{"monetizable":false}}]},"source":"\u003ca href=\"https:\/\/syncer.jp\/\" rel=\"nofollow\"\u003eSYNCER APPS WRITE\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":1528352858,"id_str":"1528352858","name":"\u3042\u3089\u3086","screen_name":"arayutw","location":"\u65e5\u672c \u6771\u4eac","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":1425,"friends_count":565,"listed_count":113,"created_at":"Tue Jun 18 17:28:51 +0000 2013","favourites_count":4464,"utc_offset":32400,"time_zone":"Asia\/Tokyo","geo_enabled":true,"verified":false,"statuses_count":35313,"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\/821911941396328448\/VjorK4J1.jpg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/821911941396328448\/VjorK4J1.jpg","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/821941553774010370\/5M2umxbl_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/821941553774010370\/5M2umxbl_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/1528352858\/1484800383","profile_link_color":"D36015","profile_sidebar_border_color":"F2E195","profile_sidebar_fill_color":"FFF7CC","profile_text_color":"0C3E53","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null,"translator_type":"regular"},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":1,"favorited":false,"retweeted":false,"possibly_sensitive":false,"possibly_sensitive_appealable":false,"lang":"ja"}

プロパティの説明

entitiesにはテキストをリッチテキスト化するための情報が含まれています。従って、メディアファイルはテキスト中のURLアドレスに該当する1つのエンティティしか含まれません。動画ファイルもサムネイル画像の情報に差し替えられています。一方、extended_entitiesには動画や画像を表示するための情報なので、全てのメディアファイルのエンティティが含まれています。個々のエンティティの構造は同じです。

description
: Array
ユーザーオブジェクトに含まれる。プロフィールの紹介文をリッチテキスト化するための情報。中身はurlsプロパティが含まれる。
hashtags
: Array
ハッシュタグのエンティティ。ツイートに含まれるハッシュタグの数だけオブジェクトを含む。各オブジェクトのプロパティは下記の通り。
text
置換後に適した文字列。
indices
テキスト中の該当部分の位置を表す配列。第1要素が開始の位置、第2要素が終了の位置。
media
: Array
メディアファイルのエンティティ。ツイートに含まれるメディアファイルの数だけオブジェクトを含む。各オブジェクトのプロパティは下記の通り。画像と動画で内容が違うので注意。
id
メディアID。数値型。
id_str
メディアID。文字列型。
indices
テキスト中の該当部分の位置を表す配列。第1要素が開始の位置、第2要素が終了の位置。
media_url
メディアファイルそのもののURL。
media_url_https
メディアファイルそのもののURL。SSL版。
url
置換後に適した文字列。短縮URL。
display_url
リッチテキスト化する時に、これに置換すると見栄えが良い文字列。URLのホスト。
expanded_url
メディアファイルを表示するページのURL。
type
メディアファイルの種類。画像はphoto、動画はvideo
sizes
リサイズされたメディアファイルの各サイズ。リサイズの種類には切り取り(crop)と、アスペクト比を維持した縮小(fit)がある。
video_info
動画ファイルの場合に、情報が含まれる。動画ファイルのアスペクト比(aspect_ratio)と、リサイズされた各サイズ(variants)。
symbols
: Array
シンボルタグのエンティティ。ツイートに含まれるシンボルタグの数だけオブジェクトを含む。各オブジェクトのプロパティは下記の通り。
text
置換後に適した文字列。
indices
テキスト中の該当部分の位置を表す配列。第1要素が開始の位置、第2要素が終了の位置。
url
: Array
ユーザーオブジェクトに含まれる。プロフィールのウェブサイトをリッチテキスト化するための情報。中身はurlsプロパティが含まれる。
urls
: Array
URLのエンティティ。ツイートやプロフィールに含まれるURLの数だけオブジェクトを含む。各オブジェクトのプロパティは下記の通り。
url
置換後に適した文字列。短縮URL。
expanded_url
本来のURL。
display_url
リッチテキスト化する時に、これに置換すると見栄えが良い文字列。URLのホスト。
indices
テキスト中の該当部分の位置を表す配列。第1要素が開始の位置、第2要素が終了の位置。
user_mentions
: Array
ユーザーメンションのエンティティ。ツイートに含まれるメンションの数だけオブジェクトを含む。各オブジェクトのプロパティは下記の通り。
screen_name
メンションを送った相手ユーザーのスクリーンネーム。
name
メンションを送った相手ユーザーの名前。
id
メンションを送った相手ユーザーのユーザーID。数値型。
id_str
メンションを送った相手ユーザーのユーザーID。文字列型。
indices
テキスト中の該当部分の位置を表す配列。第1要素が開始の位置、第2要素が終了の位置。