2013-02-13 12 views
5

YouTube APIを使用していて、ユーザーのYouTubeリンクを取得しようとしていました。表示されるのは、リンクと呼ばれるGoogle+リンクだけです。とにかく、Googleアカウント情報からユーザーのYoutube情報を取得するにはどうすればよいですか?Google API:ユーザーのYouTubeチャンネルを検索

Googleレスポンスには、jsonレスポンスにfirst_name、given_name、およびlinkがあります。

ありがとうございます!

+0

あなたが作成しているAPI呼び出しの詳細、戻ってくる返答のサンプル、および「返信」の意味の説明(例を含む)を提供することができれば、ユーザーのYouTubeリンク " –

答えて

1

それは正確に何をしたいかどうかはわからないが、Google +のAPIを使用して、ユーザーのURLを取得することができ、それらのいずれかが

詳細情報、ユーザーのYouTubeチャンネルのURLを指定できます https://developers.google.com/+/api/latest/people/get

例:

要求:

https://www.googleapis.com/plus/v1/people/117629885563933382879?key= {YOUR_API_KEY}

応答:GoogleのYouTubeのAPI channels listドキュメントを1として

{ 
"kind": "plus#person", 
"etag": "\"l9gWq2lTiBDNZWBx8kpM7h7VNYs/as5084EFycaxtFP9IxDLvhbwZKM\"", 
"birthday": "0000-12-30", 
"gender": "male", 
"urls": [ 
    { 
    "value": "http://twitter.com/matiasmolinas", 
    "type": "other" 
    }, 
    { 
    "value": "http://gplus.to/matiasmolinas", 
    "type": "other" 
    }, 
    { 
    "value": "http://ar.linkedin.com/in/matiasmolinas", 
    "type": "other" 
    }, 
    { 
    "value": "https://www.facebook.com/matias.molinas", 
    "type": "other" 
    }, 
    { 
    "value": "http://www.youtube.com/user/matiasmolinasvideo", 
    "type": "other" 
    }, 
    { 
    "value": "http://stackoverflow.com/users/1427200/matias-molinas", 
    "type": "other" 
    }, 
    { 
    "value": "http://santafegtug.blogspot.com/", 
    "type": "other" 
    }, 
    { 
    "value": "http://fuse21.blogspot.com/", 
    "type": "other" 
    }, 
    { 
    "value": "http://lookthiscode.blogspot.com.ar/", 
    "type": "other" 
    }, 
    { 
    "value": "https://yt-topic-explorer.googlecode.com/git/dist/index.html", 
    "type": "other" 
    }, 
    { 
    "value": "http://santafegtug.appspot.com/", 
    "type": "other" 
    } 
], 
"objectType": "person", 
"id": "117629885563933382879", 
"displayName": "Matias Molinas", 
"name": { 
    "familyName": "Molinas", 
    "givenName": "Matias" 
}, 
"aboutMe": "Citas favoritas:<br /><br />Dentro de veinte años te sentirás más desilusionado por las cosas que no hiciste que por aquéllas que hiciste. Así que suelta las amarras. Navega fuera de la bahía segura. Atrapa los alisios en tus velas. Explora. Sueña. Descubre.<br />", 
"url": "https://plus.google.com/117629885563933382879", 
"image": { 
    "url": "https://lh3.googleusercontent.com/-AJKFDGod6us/AAAAAAAAAAI/AAAAAAAAD64/Olccnle-qH4/photo.jpg?sz=50" 
}, 
"organizations": [ 
    { 
    "name": "UNER", 
    "title": "Bioingenieria", 
    "type": "school", 
    "primary": false 
    }, 
    { 
    "name": "Software Consultant", 
    "title": "Software Consultant", 
    "type": "work", 
    "startDate": "2011", 
    "endDate": "2011", 
    "primary": true 
    }, 
    { 
    "name": "Software Santa Fe", 
    "type": "work", 
    "endDate": "2011", 
    "primary": false 
    } 
], 
"placesLived": [ 
    { 
    "value": "Santa Fe, Argentina", 
    "primary": true 
    } 
], 
"isPlusUser": true, 
"verified": false, 
"cover": { 
    "layout": "banner", 
    "coverPhoto": { 
    "url": "https://lh3.googleusercontent.com/-DjGbmNDlV3U/UNCgpGJu_WI/AAAAAAAAD7Q/7Uk2WidwxnI/w940-h428/gdesummit.png", 
    "height": 428, 
    "width": 940 
    }, 
    "coverInfo": { 
    "topImageOffset": -83, 
    "leftImageOffset": 0 
    } 
} 
} 
+0

これはまさに私が欲しいと思われるものです。それを今チェックアウトする。 –

+0

これは非常に便利です:https://developers.google.com/oauthplayground/ 私はまだどちらかの方法で作業することはありませんでしたが、今私はAPIのエンドポイントの完全なリストを持っていると私は近いと思う:) –

+6

希望みんなこのコメントを見る。上記のリクエストは、リンクの**その他**ラベルの下にある場合のみYouTubeチャンネルを返します。 YouTubeのラベルにある場合、結果には表示されません。だからそれは、千のようなアカウントのうち、一握りのチャンネルでしか動作しません。指定したG + IDに関連付けられているすべてのチャンネルを返す別の方法がありますか? – unknown

0

、あなたが特定のGoogleユーザーに関連するすべてのYouTubeチャンネルを含むJSONレスポンスを得ることができます。

ステップ1

明らかにあなたは、Googleの開発者向けAPI(あなたがYouTubeのスコープに使用していることを保証する:https://www.googleapis.com/auth/youtube)にログインするためにはOAuth 2.0を使用していることを確認する必要があります。これは、ユーザー固有のデータをロードするためにaccess_tokenが必要なためです。

ステップ2

channels list APIを経由してチャンネルを見つけることができますなど、ユーザ名チャネルIDを... ID文字列は、しかし必要ないです。代わりに、特定のGoogleユーザーが所有するYouTubeチャンネルを取得するためににmineブールパラメータを設定することができます.GoogleユーザーのIDを指定する必要はありません。access_tokenは、どのユーザーがデータを読み込みます)。 APIを使用するためには

、( 'YOUR_ACCESS_TOKEN_HERE' あなたaccess_tokenを置き換える)、次のURLを使用して要求を行います。ここでは

https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&mine=true&access_token=YOUR_ACCESS_TOKEN_HERE

はあなたが買ってあげることJSON応答であります:

{ 
"kind": "youtube#channelListResponse", 
"etag": "xxxxxxxxxxxxxxxxxxxxxxxxxxx", 
"pageInfo": { 
    "totalResults": 1, 
    "resultsPerPage": 1 
}, 
"items": [ 
    { 
    "kind": "youtube#channel", 
    "etag": "xxxxxxxxxxxxxxxxxxxxxxxxxxx", 
    "id": "YOUTUBE_CHANNEL_ID", 
    "snippet": { 
    "title": "Daniel Sadjadian", 
    "description": "I’m Daniel Sadjadian - Car enthusiast, computer programmer & entrepreneur running my own business. I live life to the max and try my best to get the most out of each day. Every moment counts :)", 
    "customUrl": "danielsadjadian", 
    "publishedAt": "2013-11-09T19:47:41.000Z", 
    "thumbnails": { 
    "default": { 
     "url": "https://yt3.ggpht.com/-EF0LibpIsEY/AAAAAAAAAAI/AAAAAAAAAAA/n0mUHQnyfkc/s88-c-k-no-mo-rj-c0xffffff/photo.jpg" 
    }, 
    "medium": { 
     "url": "https://yt3.ggpht.com/-EF0LibpIsEY/AAAAAAAAAAI/AAAAAAAAAAA/n0mUHQnyfkc/s240-c-k-no-mo-rj-c0xffffff/photo.jpg" 
    }, 
    "high": { 
     "url": "https://yt3.ggpht.com/-EF0LibpIsEY/AAAAAAAAAAI/AAAAAAAAAAA/n0mUHQnyfkc/s240-c-k-no-mo-rj-c0xffffff/photo.jpg" 
    } 
    }, 
    "localized": { 
    "title": "Daniel Sadjadian", 
    "description": "I’m Daniel Sadjadian - Car enthusiast, computer programmer & entrepreneur running my own business. I live life to the max and try my best to get the most out of each day. Every moment counts :)" 
    }, 
    "country": "GB" 
    }, 
    "contentDetails": { 
    "relatedPlaylists": { 
    "likes": "LLXQYiggNxzVJ51ofKyG2ZUg", 
    "favorites": "FLXQYiggNxzVJ51ofKyG2ZUg", 
    "uploads": "UUXQYiggNxzVJ51ofKyG2ZUg", 
    "watchHistory": "HL", 
    "watchLater": "WL" 
    } 
    }, 
    "statistics": { 
    "viewCount": "30305", 
    "commentCount": "0", 
    "subscriberCount": "100", 
    "hiddenSubscriberCount": false, 
    "videoCount": "25" 
    } 
    } 
] 
} 

JSONレスポンスには、チャンネルIDを含むチャンネルを表示します。他のYouTube APIと組み合わせてチャンネルIDを使用して、チャンネルの動画/再生リスト/アクティビティ/などを読み込むことができます。