正在上载到youtube(v3),在getAccessToken处失败


Uploading to youtube (v3), failing at getAccessToken

    require_once ('Google/Client.php');
    require_once ('Google/Http/MediaFileUpload.php');
    require_once ('Google/Service/Drive.php');
    $client = new Google_Client();
    $client->setClientId('clitentid');
    $client->setClientSecret('secret');
    $client->setRedirectUri('/');
    $client->addScope("https://www.googleapis.com/auth/drive");
    $service = new Google_Service_Drive($client);
    if ($client->getAccessToken())
    {
        echo __LINE__;die;
        $file = new Google_Service_Drive_DriveFile();
        $file->title = "Big File";
        $chunkSizeBytes = 1 * 1024 * 1024;
        // Call the API with the media upload, defer so it doesn't immediately return.
        $client->setDefer(true);
        $request = $service->files->insert($file);
        // Create a media file upload to represent our upload process.
        $media = new Google_Http_MediaFileUpload(
            $client,
            $request,
            'text/plain',
            null,
            true,
            $chunkSizeBytes
        );
        $media->setFileSize(filesize('myfile'));
        // Upload the various chunks. $status will be false until the process is
        // complete.
        $status = false;
        $handle = fopen('myfile', "rb");
        while (!$status && !feof($handle)) {
            $chunk = fread($handle, $chunkSizeBytes);
            $status = $media->nextChunk($chunk);
        }
        // The final value of $status will be the data from the API for the object
        // that has been uploaded.
        $result = false;
        if ($status != false) {
            $result = $status;
        }
        fclose($handle);
    }
    else
    {
        echo 'fail';
    }

客户端id和secret是我可以下载的JSON代码(client_id和client_secret字段(。所以,它失败了。我哪里能失败呢?

EDIT:$client->getAuth()->getAccessToken()返回"[]">

这是php客户端库上的一个错误,刚刚修复。

https://github.com/google/google-api-php-client/pull/181

下载master分支。