我正在使用cURL通过Google API从用户那里获取所有电子邮件。关注https://developers.google.com/admin-sdk/email-audit/#retrieving_all_email_monitors_of_a_source_user。
根据本教程,服务器将“201 Created”状态代码返回成功。但是,我的结果返回'200 OK'代码。
这是代码授权
$data = array(
'accountType' => 'HOSTED_OR_GOOGLE',
'Email' => 'myEmail',
'Passwd' => 'myPassword',
'source'=>'PHP-cUrl-Example',
'service'=>'apps');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
以下是检索源用户的所有电子邮件监视器的代码
preg_match("/Auth=([a-z0-9_-]+)/i", $response, $matches);
$auth = $matches[1];
$header = array('Content-Type: application/atom+xml; charset=utf-8',
'Authorization: GoogleLogin auth='.trim($auth),
);
$url_email ="https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/mydomain/username";
curl_setopt($ch, CURLOPT_URL, $url_email);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
$response = curl_exec($ch);
$response = simplexml_load_string($response);
curl_close($ch);
print_r($response);
请帮帮我?
答案 0 :(得分:0)
API允许您request the status of a single export request的网址为:
https://apps-apis.google.com/a/feeds/compliance/audit/mail/export/ {域名} / {来源用户名} / {邮箱requestId}
或all requests across the domain请求:
https://apps-apis.google.com/a/feeds/compliance/audit/mail/export/ {域名}?fromDate = {fromDate}
没有像您尝试的那样检索给定用户的所有请求状态的操作。
我建议您使用GAM create the request确认您已成功创建审核请求。 GAM会在成功时向您显示请求ID。然后,您可以尝试使用代码获取单个请求的结果。