How to use API KEY with YouTube in angularjs and list videos in a playlist?

前端 未结 2 1399
再見小時候
再見小時候 2020-12-06 19:27

I want to list a bunch of videos from YouTube in my mobile app using angularjs. Preferrably I\'d like to list all videos of a user/channels specific playlist.

I\'ve

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 20:16

    You have to use Google APIs Client Library so that gapi object will be defined and examples from google will work. Include this in the bottom of the page:

    
    

    And than define callback which will proceed with authorization and your logic:

    googleApiClientReady = function() {
      gapi.auth.init(function() {
        // Other code following the example
      });
    }
    

    In general as per Google documentation there are

    1. The application loads the JavaScript client library.

    2. The application references its API key, which authenticates the application with Google services.

    3. If the application needs access to the user's personal information, it opens a session with a Google auth server. The auth server opens a dialog box which prompts the user to authorize the use of personal information.

    4. The application loads the API for the Google service.

    5. The application initializes a request object (also called a service object) that specifies the data to be returned by the API.

    6. The application executes the request and processes the data returned by the API.

    Here is a working example of basic google API authorization process

提交回复
热议问题