2013-03-07 9 views
6

GoogleのObjective-C Youtube APIを使用して、YouTubeチャンネルの再生リストを取得しようとしています。Objective-C APIを使用してYoutubeチャンネルの再生リストを取得する

-IからGoogleの公式APIをダウンロード: http://code.google.com/p/gdata-objectivec-client/source/browse/#svn%2Ftrunk%2FExamples%2FYouTubeSample

しかし、サンプルは、Appは本当に何もしません - それもないのiOSアプリのサンプルを。 Mac OS Appであるらしい。 Read-Meファイルには、「このサンプルはビルドアンドランプロセスの一部としてGTL.frameworkを自動的にビルドしてコピーする必要があります。

[OK] ...次に何ですか?

これをiPhoneアプリケーションでどのように動作させるにはどうしますか?

私はこの作業を行うための実際の指示は見つかりませんでした。

私たちはここで何をすべきでしょうか?

答えて

0

でソースコードを試すことができます私は、彼らが一例として与えられているMAC OSXアプリを使用する方法でそれを把握しようとしている日半を費やしてきました。私は私がYouTubeから持っているすべてのアップロードされたビデオを得るために構築するために管理するiPhoneアプリで終わった。それを動作させるためにはYouTubeProject

リンクに

  • あなたはLTMasterViewController.m->(GDataServiceGoogleYouTube *)youTubeServiceでグーグル
  • からGDataのプロジェクトを追加する必要があります。putあなたのユーザー名とパスワード
+0

"警告:Google Data APIの最新のドキュメントは、Google Data APIディレクトリにリストされている古いAPIにのみ適用されます。特定の新しいAPIについては、そのAPIのドキュメントを参照してください。新しいAPIでリクエストを承認する方法については、Googleアカウントの認証と承認を参照してください。 https://developers.google.com/gdata/ GDataを置き換える必要がある理由がわからない – Zsolt

0

YouTube用の "gdata-objectivec-client"は、JSON-API Linkで置き換えられました。 YouTubeまでスクロールします。

JSON-APIをサポートするための詳細はLinkです。

プレイリストを取得するにはLinkをご覧ください。

0

紛失した初心者の方:フェッチ、解析、表示などのサイクル全体を理解し、YouTubeチャンネルの動画をテーブルビューに具体的に表示するサンプル機能を検討してください。ここではテーブルビューの部分を書いていません。

-(void)initiateRequestToYoutubeApiAndGetChannelInfo 
{ 
NSString * urlYouCanUseAsSample = @"https://www.googleapis.com/youtube/v3/search?key={YOUR_API_KEY_WITHOUT_CURLY_BRACES}&channelId={CHANNEL_ID_YOU_CAN_GET_FROM_ADDRESS_BAR_WITHOUT_CURLY_BRACES}&part=snippet,id&order=date&maxResults=20"; 



NSURL *url = [[NSURL alloc] initWithString: urlYouCanUseAsSample]; 

// Create your request 
NSURLRequest *request = [NSURLRequest requestWithURL:url]; 



// Send the request asynchronously remember to reload tableview on global thread 
[NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { 

// Callback, parse the data and check for errors 
if (data && !connectionError) { 
    NSError *jsonError; 

    NSDictionary *jsonResult = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError]; 

    if (!jsonError) { 
    // better put a breakpoint here to see what is the result and how it is brought to you. Channel id name etc info should be there 

     NSLog(@"%@",jsonResult); 

    /// separating "items" dictionary and making array 

     // 
id keyValuePairDict = jsonResult; 
NSMutableArray * itemList = keyValuePairDict[@"items"]; 
     for (int i = 0; i< itemList.count; i++) { 


    /// separating VIDEO ID dictionary from items dictionary and string video id 
     id v_id0 = itemList[i]; 
     NSDictionary * vid_id = v_id0[@"id"]; 
     id v_id = vid_id; 
     NSString * video_ID = v_id[@"videoId"]; 

    //you can fill your local array for video ids at this point 

     //  [video_IDS addObject:video_ID]; 

    /// separating snippet dictionary from itemlist array 
     id snippet = itemList[i]; 
     NSDictionary * snip = snippet[@"snippet"]; 

    /// separating TITLE and DESCRIPTION from snippet dictionary 
     id title = snip; 
     NSString * title_For_Video = title[@"title"]; 
     NSString * desc_For_Video = title[@"description"]; 

    //you can fill your local array for titles & desc at this point 

      // [video_titles addObject:title_For_Video]; 
      // [video_description addObject:desc_For_Video]; 




    /// separating thumbnail dictionary from snippet dictionary 

     id tnail = snip; 
     NSDictionary * thumbnail_ = tnail[@"thumbnails"]; 

    /// separating highresolution url dictionary from thumbnail dictionary 

     id highRes = thumbnail_; 
     NSDictionary * high_res = highRes[@"high"]; 

    /// separating HIGH RES THUMBNAIL IMG URL from high res dictionary 

     id url_for_tnail = high_res; 
     NSString * thumbnail_url = url_for_tnail[@"url"]; 
    //you can fill your local array for titles & desc at this point 

      [video_thumbnail_url addObject:thumbnail_url]; 


     } 
    // reload your tableview on main thread 
//[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; 
performSelectorOnMainThread:@selector(reloadInputViews) withObject:nil waitUntilDone:NO]; 


    // you can log all local arrays for convenience 
    // NSLog(@"%@",video_IDS); 
     // NSLog(@"%@",video_titles); 
     // NSLog(@"%@",video_description); 
     // NSLog(@"%@",video_thumbnail_url); 
    } 
    else 
    { 
     NSLog(@"an error occurred"); 
    } 
    } 
}]; 

} 
関連する問題