Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.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 谷歌电子邮件审计API管理SDK_Php_Google Api_Google Admin Sdk_Gmail Api_Google Email Audit Api - Fatal编程技术网

Php 谷歌电子邮件审计API管理SDK

Php 谷歌电子邮件审计API管理SDK,php,google-api,google-admin-sdk,gmail-api,google-email-audit-api,Php,Google Api,Google Admin Sdk,Gmail Api,Google Email Audit Api,我将使用用户abc的电子邮件审核API列出我用户的电子邮件。到目前为止,我的代码是 $xml = " <atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'> <apps:property name='destUserName' value='abc'/> <apps:property name='b

我将使用用户abc的电子邮件审核API列出我用户的电子邮件。到目前为止,我的代码是

$xml = "
    <atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
   <apps:property name='destUserName' value='abc'/>
   <apps:property name='beginDate' value='2009-06-15 00:00'/>
   <apps:property name='endDate' value='2015-06-30 23:20'/>
   <apps:property name='incomingEmailMonitorLevel' value='FULL_MESSAGE'/>
   <apps:property name='outgoingEmailMonitorLevel' value='HEADER_ONLY'/>
   <apps:property name='draftMonitorLevel' value='FULL_MESSAGE'/>
   <apps:property name='chatMonitorLevel' value='FULL_MESSAGE'/>
</atom:entry>
";


$abc = 'mypublicAPI';
$cred = new Google_Auth_AssertionCredentials(
  'myEmail',
  array(
      'https://apps-apis.google.com/a/feeds/compliance/audit',
    ),$abc
);


$client->setAssertionCredentials($cred);
$domain = 'mydomain';
$username = 'abc';
if($client->getAuth()->isAccessTokenExpired()) {
    $client->getAuth()->refreshTokenWithAssertion($cred);
}
$url = "https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/" . $domain .'/'. $username;                                                        
$req = new Google_Http_Request($url, 'POST');
$req->setPostBody($xml);

$token = json_decode($client->getAccessToken(), true);

$req->setRequestHeaders(
    array(
        'Content-Type'=> 'application/atom+xml; charset=utf-8',
        'Authorization'=> 'Bearer ' . $token['access_token'] . '',
    )
);
代码返回

object(Google_Http_Request)#52 (14) { ["batchHeaders":"Google_Http_Request":private]=> array(3) { ["Content-Type"]=> string(16) "application/http" ["Content-Transfer-Encoding"]=> string(6) "binary" ["MIME-Version"]=> string(3) "1.0" } ["queryParams":protected]=> array(0) { } ["requestMethod":protected]=> string(4) "POST" ["requestHeaders":protected]=> array(2) { ["content-type"]=> string(35) "application/atom+xml; charset=utf-8" ["authorization"]=> string(90) "Bearer ya29.tAC7zkWiQjV_KcSSQZhmUQGuXgXvN9LMVBERhflX2vs4qsfGGVQoBRIHSLGawsLLxYNPaZuqQgtKug" } ["baseComponent":protected]=> string(28) "https://apps-apis.google.com" ["path":protected]=> string(85) "/a/feeds/compliance/audit/mail/monitor/mydomain/abc" ["postBody":protected]=> string(597) " " ["userAgent":protected]=> NULL ["canGzip":protected]=> NULL ["responseHttpCode":protected]=> NULL ["responseHeaders":protected]=> NULL ["responseBody":protected]=> NULL ["expectedClass":protected]=> NULL ["accessKey"]=> NULL }

任何帮助???

您的代码已经创建了请求,但尚未执行。您可以使用以下代码执行请求:

$resp = $client->execute($req);
$resp = $client->execute($req);