我将使用用户 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'] . '',
)
);
但是代码什么也不返回。甚至没有像文档说的 http 状态代码: https ://developers.google.com/admin-sdk/email-audit/#creating_a_new_email_monitor
但是,当我这样做时
var_dump($req);
代码返回
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 }
有什么帮助吗??