javascript - Getting error on gapi.client.youtube -


i using google youtube api check if user hit or not youtube videos. using following code

 // global variables googleauth object, auth status.   var googleauth;    /**    * load api's client , auth2 modules.    * call initclient function after modules load.    */   function handleclientload() {     gapi.load('client:auth2', initclient);   }    function initclient() {     // initialize gapi.client object, app uses make api requests.     // api key , client id api console.     // 'scope' field specifies space-delimited list of access scopes      gapi.client.init({         'clientid': 'replace_me',         'discoverydocs': ['https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest'],         'scope': 'https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtubepartner'     }).then(function () {       googleauth = gapi.auth2.getauthinstance();        // listen sign-in state changes.       googleauth.issignedin.listen(updatesigninstatus);        // handle initial sign-in state. (determine if user signed in.)       setsigninstatus();        // call handleauthclick function when user clicks on "authorize" button.       $('#execute-request-button').click(function() {         handleauthclick(event);       });      });   }    function handleauthclick(event) {     // sign user in after click on auth button.     googleauth.signin();   }    function setsigninstatus() {     var user = googleauth.currentuser.get();     isauthorized = user.hasgrantedscopes('https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtubepartner');     // toggle button text , displayed statement based on current auth status.     if (isauthorized) {       definerequest();     }   }    function updatesigninstatus(issignedin) {     setsigninstatus();   }    function createresource(properties) {     var resource = {};     var normalizedprops = properties;     (var p in properties) {       var value = properties[p];       if (p && p.substr(-2, 2) == '[]') {         var adjustedname = p.replace('[]', '');         if (value) {           normalizedprops[adjustedname] = value.split(',');         }         delete normalizedprops[p];       }     }     (var p in normalizedprops) {       // leave properties don't have values out of inserted resource.       if (normalizedprops.hasownproperty(p) && normalizedprops[p]) {         var proparray = p.split('.');         var ref = resource;         (var pa = 0; pa < proparray.length; pa++) {           var key = proparray[pa];           if (pa == proparray.length - 1) {             ref[key] = normalizedprops[p];           } else {             ref = ref[key] = ref[key] || {};           }         }       };     }     return resource;   }    function removeemptyparams(params) {     (var p in params) {       if (!params[p] || params[p] == 'undefined') {         delete params[p];       }     }     return params;   }    function executerequest(request) {     request.execute(function(response) {       console.log(response);     });   }    function buildapirequest(requestmethod, path, params, properties) {     params = removeemptyparams(params);     var request;     if (properties) {       var resource = createresource(properties);       request = gapi.client.request({           'body': resource,           'method': requestmethod,           'path': path,           'params': params       });     } else {       request = gapi.client.request({           'method': requestmethod,           'path': path,           'params': params       });     }     executerequest(request);   }    /***** end boilerplate code *****/    function videosgetrating(params) {   params = removeemptyparams(params); // see full sample function   var request = gapi.client.youtube.videos.getrating(params);   executerequest(request); }     function definerequest() {     videosgetrating({'id': 'ks-_mh1qhmc,c0kyu2j0tm4,eiho2s0zahi',                  'onbehalfofcontentowner': ''});    } 

but getting error in code

typeerror: gapi.client.youtube undefined 

i check many posts on stackoverflow regarding not me out. have no idea this.please let me know if have idea regarding

thanks


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -