Php 谷歌服务认证谷歌IO异常,消息为';协议“;https";libcurl中不支持或禁用

Php 谷歌服务认证谷歌IO异常,消息为';协议“;https";libcurl中不支持或禁用,php,api,youtube,Php,Api,Youtube,我正在使用Youtube数据api,它在localhost上正常工作,但当我尝试在live server上访问此代码时,它不工作。提出一个例外: 未捕获异常“谷歌IO异常”和消息“协议” 中的libcurl中不支持或禁用“https” /home/legendude/public_html/newUpload/Google/IO/Curl.php:115堆栈 跟踪:#0 /home/legendude/public_html/newUpload/Google/IO/Abstract.php(13

我正在使用Youtube数据api,它在localhost上正常工作,但当我尝试在live server上访问此代码时,它不工作。提出一个例外:

未捕获异常“谷歌IO异常”和消息“协议” 中的libcurl中不支持或禁用“https” /home/legendude/public_html/newUpload/Google/IO/Curl.php:115堆栈 跟踪:#0 /home/legendude/public_html/newUpload/Google/IO/Abstract.php(136): Google_IO_Curl->executeRequest(对象(Google_Http_请求))\1 /home/legendude/public_html/newUpload/Google/Auth/OAuth2.php(111): Google_IO_Abstract->makeRequest(对象(Google_Http_Request))\2 /home/legendude/public_html/newUpload/Google/Client.php(128): Google_Auth_OAuth2->authenticate('4/x7_AOHFKvmlea…',false)#3 /home/legendude/public_html/newUpload/youtube.php(44): Google_Client->authenticate('4/x7_AOHFKvmlea…')#4{main}被抛出

这是我的代码youtube.php-:

<?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's 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`
发件人:

将URL传递给curl使用时,它可能会响应不支持或禁用特定协议。这个错误消息的特殊表达方式是因为curl没有在内部区分特定协议是否不受支持(即,从未添加任何知道如何使用该协议的代码)或是否被显式禁用。curl可以被构建为只支持一组给定的协议,其余的将被禁用或不支持

还有更多:

要将https://支持添加到以前构建但报告不支持https://的curl中,您应该仔细查看文档和日志,并检查配置脚本为什么找不到SSL libs和/或include文件