Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 没有从驱动器接收webhook通知,为什么?_Php_Google Drive Api_Google Api Php Client - Fatal编程技术网

Php 没有从驱动器接收webhook通知,为什么?

Php 没有从驱动器接收webhook通知,为什么?,php,google-drive-api,google-api-php-client,Php,Google Drive Api,Google Api Php Client,我试图使用Google Drive SDK接收帐户所有更改的通知,我按照以下步骤操作,然后创建并运行,我从以下位置获取此对象Google\u服务\u Drive\u频道: 因此,我转到google驱动器帐户来移动一些文件,但在指定的位置“address”参数内,我仍然没有从webhook收到任何东西 仅在创建频道时,我才收到X-Goog-Resource-State=sync头,但其他事件(添加、删除、垃圾、取消垃圾、更改、更新)不会收到 任何帮助,谢谢我猜您正在编辑的驱动器帐户与该服务帐户没有

我试图使用Google Drive SDK接收帐户所有更改的通知,我按照以下步骤操作,然后创建并运行,我从以下位置获取此对象
Google\u服务\u Drive\u频道

因此,我转到google驱动器帐户来移动一些文件,但在指定的位置“address”参数内,我仍然没有从webhook收到任何东西

仅在创建频道时,我才收到
X-Goog-Resource-State=sync
头,但其他事件(添加、删除、垃圾、取消垃圾、更改、更新)不会收到


任何帮助,谢谢

我猜您正在编辑的驱动器帐户与该服务帐户没有关联,因为我没有看到您在任何地方使用子参数。您是否可以使用基于web的OAuth 2.0进行测试,以便确定它是否可以访问与您正在修改的驱动器帐户相同的驱动器帐户。查看应用程序帐户上的驱动器文档,了解更多信息:

这是我的错误的解决方案

$client = new Google_Client();
$client->setApplicationName("APP_NAME");
$service = new Google_Service_Drive($client);
$key = file_get_contents('my_private_key_location.p12');
$cred = new Google_Auth_AssertionCredentials(
  'email_address_from_the_client@developer.gserviceaccount.com',
  array('https://www.googleapis.com/auth/drive'),
  $key
);
$client->setAssertionCredentials($cred);


// Channel
$channel = new Google_Service_Drive_Channel();
$channel->setId(uniqid());
$channel->setAddress('https://my.custom.url');
$channel->setKind('api#channel');
$channel->setType('web_hook');
$test = $service->changes->watch($channel);
print_r($test);


// Response printing the result
Google_Service_Drive_Channel Object
(
    [address] => 
    [expiration] => 1407171497000
    [id] => xxxxxxxxxxxxxxxxxx
    [kind] => api#channel
    [params] => 
    [payload] => 
    [resourceId] => xxxxxxxxxxxxxxxxxxxx
    [resourceUri] => https://www.googleapis.com/drive/v2/changes?includeDeleted=true&includeSubscribed=true&maxResults=100&alt=json
    [token] => 
    [type] => 
    [modelData:protected] => Array
        (
        )

    [processed:protected] => Array
        (
        )

)