Google services authentication Google_IO_Exception with "https protocol" not supported or not disabled in libcurl

I am using the Youtube api data, working correctly on localhost, but when I try to access this code on a live server, it doesn't work. giving an exception:

Cannot throw "Google_IO_Exception" with message "Protocol" https "is not supported and is not disabled in libcurl 'in / home / legenddude / public _html / newUpload / Google / IO / Curl.php: 115 Stack Trail: # 0 / home / legenddude / public _html / newUpload / Google / IO / Abstract.php (136): Google_IO_Curl-> executeRequest (object (Google_Http_Request)) # 1 / home / legenddude / public _html / newUpload / Google / Auth / OAuth2.php (111): Google_IO_Abstract -> makeRequest (object (Google_Http_Request)) # 2 / home / legenddude / public _html / newUpload / Google / Client.php (128): Google_Auth_OAuth2-> authenticate ('4 / x7_AOHFKvmlea ...', false) # 3 / home / legenddude / public _html / newUpload / youtube.php (44): Google_Client-> authenticate ('4 / x7_AOHFKvmlea ...') # 4 {main} thrown at

Here is my youtube.php code -:

<?php
 // Call set_include_path() as needed to point to your client library.
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
set_include_path($_SERVER['DOCUMENT_ROOT'] . '/newUpload/');

require_once 'Google/autoload.php';
require_once 'Google/Client.php';
require_once 'Google/Service/YouTube.php';
session_start();
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
/*
 * You can acquire an OAuth 2.0 client ID and client secret from the
 * {{ Google Cloud Console }} <{{ https://cloud.google.com/console }}>
 * For more information about using OAuth 2.0 to access Google APIs, please see:
 * <https://developers.google.com/youtube/v3/guides/authentication>
 * Please ensure that you have enabled the YouTube Data API for your project.
 */
$OAUTH2_CLIENT_ID = '619899784025-5nn2tqomt3cr6g231qd93nr0lsojdvq9.apps.googleusercontent.com';
$OAUTH2_CLIENT_SECRET = '49K6Ou9PK9n1aamAeg27fnIC';
$REDIRECT = 'http://www.legenddude.com/newUpload/youtube.php';
$APPNAME = "legenddudes";


$client = new Google_Client();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$client->setScopes("https://www.googleapis.com/auth/youtube");
$client->setRedirectUri($REDIRECT);
$client->setApplicationName($APPNAME);
$client->setAccessType('online');
$client->setDeveloperKey('619899784025-5nn2tqomt3cr6g231qd93nr0lsojdvq9@developer.gserviceaccount.com');


// Define an object that will be used to make all API requests.
$youtube = new Google_Service_YouTube($client);

if (isset($_GET['code'])) {
    if (strval($_SESSION['state']) !== strval($_GET['state'])) {
        die('The session state did not match.');
    }
   //echo $_SESSION['state'];exit;
    $client->authenticate($_GET['code']);
    $_SESSION['token'] = $client->getAccessToken();

}

if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);
    echo '<code>' . $_SESSION['token'] . '</code>';
}

// Check to ensure that the access token was successfully acquired.
if ($client->getAccessToken()) {
    try {
        // Call the channels.list method to retrieve information about the
        // currently authenticated user channel.
        $channelsResponse = $youtube->channels->listChannels('contentDetails', array(
            'mine' => 'true',
        ));

        $htmlBody = '';
        foreach ($channelsResponse['items'] as $channel) {
            // Extract the unique playlist ID that identifies the list of videos
            // uploaded to the channel, and then call the playlistItems.list method
            // to retrieve that list.
            $uploadsListId = $channel['contentDetails']['relatedPlaylists']['uploads'];

            $playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet', array(
                'playlistId' => $uploadsListId,
                'maxResults' => 50
            ));

            $htmlBody .= "<h3>Videos in list $uploadsListId</h3><ul>";
            foreach ($playlistItemsResponse['items'] as $playlistItem) {
                $htmlBody .= sprintf('<li>%s (%s)</li>', $playlistItem['snippet']['title'],
                    $playlistItem['snippet']['resourceId']['videoId']);
            }
            $htmlBody .= '</ul>';
        }
    } catch (Google_ServiceException $e) {
        $htmlBody .= sprintf('<p>A service error occurred: <code>%s</code></p>',
            htmlspecialchars($e->getMessage()));
    } catch (Google_Exception $e) {
        $htmlBody .= sprintf('<p>An client error occurred: <code>%s</code></p>',
            htmlspecialchars($e->getMessage()));
    }

    $_SESSION['token'] = $client->getAccessToken();
} else {
    $state = mt_rand();
    $client->setState($state);
    $_SESSION['state'] = $state;

    $authUrl = $client->createAuthUrl();
    $htmlBody = <<<END
  <h3>Authorization Required</h3>
  <p>You need to <a href="$authUrl">authorise access</a> before proceeding.<p>
END;
}
?>

<!doctype html>
<html>
<head>
    <title>My Uploads</title>
</head>
<body>
<?php echo $htmlBody?>
</body>
</html>`enter code here`

      

+3


source to share


1 answer


From curl_faq :

When submitting a curl url, it may respond that a particular protocol is not supported or disabled. The concrete way of expressing this error is that curl makes no distinction internally, regardless of whether a particular protocol is supported (i.e., no code has ever been added that knows how to speak that protocol) or if it is explicitly disabled. curl can only be built to support a specific set of protocols, and the rest will be disabled or not supported.



And further:

To get support for https: // in curl, which was previously built but reports that https: // is not supported, you have to dig through the doc and logs and check why the configure script doesn't support finding SSL files and / or include files.

0


source







All Articles