0

Error is return in youtube data api call:https://www.googleapis.com/youtube/v3/captions/id Other api is working with same code for google youtube api's. Any one with past experience with this issue can share his/her experience. Thanks in advance.

        try{
        
            $client = new Google_Client();
            $client->setApplicationName('My First Project');
            $client_id = get_option('gapi_client_id');
            $client_secret = get_option('gapi_client_secret');
            $redirect_uri = 'https://income.tube/wp-admin/admin.php?page=rnd-eytes';
            $simple_api_key =  get_option('rnd-eyts');
            $client->setClientId($client_id);
            $client->setClientSecret($client_secret);
            $client->setRedirectUri($redirect_uri);
            $client->setDeveloperKey($simple_api_key);
            $client->setScopes([
                    'https://www.googleapis.com/auth/youtube.force-ssl',
                    'https://www.googleapis.com/auth/youtube.readonly',
                    'https://www.googleapis.com/auth/youtubepartner'
                ]); 
            $client->setAccessType('offline');
            echo $authCode = get_option('gapi_auth_code');
            $accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
            $client->setAuthConfig($access_token);  
            
            // Get the authorized Guzzle HTTP client.
            $http = $client->authorize();
            $fp = fopen(__DIR__ . '/Libs/YOUR_FILE', 'w');
            
            // Exchange authorization code for an access token.
            $accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
            $queryParams = [
                'tfmt' => 'vtt',
                'tlang' => 'fr'
            ];
            
        
            $response = $http->request(
              'GET',
              '/youtube/v3/captions/OdIfTQmbuCS8lIzTWpQoHP66BOQh1VfTCmNAH-qo6vE=',
              [
                'query' => $queryParams
              ]
            );
            echo '<pre>';
            print_r($response);
            echo '</pre>';
            fwrite($fp, $response->getBody()->getContents());
            fclose($fp);
        }catch(Exception $e){
            //catch the exception here
            echo '<pre>';
            print_r($e);
            echo '</pre>';
        }
        

Error message of youtube data api caption

Error message of youtube data api caption

Error message of youtube data api caption

Sarbjit Singh
  • 11
  • 1
  • 3

0 Answers0