Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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 Google Apps电子邮件审计API:发布创建用户监视器的请求';s邮箱_Php_Email_Google Apps - Fatal编程技术网

Php Google Apps电子邮件审计API:发布创建用户监视器的请求';s邮箱

Php Google Apps电子邮件审计API:发布创建用户监视器的请求';s邮箱,php,email,google-apps,Php,Email,Google Apps,使用谷歌应用程序电子邮件审核API尝试创建一个监视器,该监视器将复制用户邮箱中的所有信件rabbit@mydomain.com至auditor@mydomain.com。在接收到错误消息时:“prolog中不允许有内容。” $url='1!'https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/mydomain.com/rabbit'; $txtXML=” 关于授权请求: https://developers.goo

使用谷歌应用程序电子邮件审核API尝试创建一个监视器,该监视器将复制用户邮箱中的所有信件rabbit@mydomain.comauditor@mydomain.com。在接收到错误消息时:“prolog中不允许有内容。

$url='1!'https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/mydomain.com/rabbit';
$txtXML=”

关于授权请求: https://developers.google.com/admin-sdk/email-audit/auth

对服务器到服务器应用程序使用OAuth 2.0: https://developers.google.com/identity/protocols/OAuth2ServiceAccount

 $url = 'https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/mydomain.com/rabbit';

 $txtXML  = "<atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>";
 $txtXML .= "<apps:property name='destUserName' value='auditor'/>";
 $txtXML .= "<apps:property name='endDate' value='2015-12-31 00:00'/>";
 $txtXML .= "</atom:entry>";

 $post_data = array( "xml" => $txtXML );

 $context = stream_context_create(
     array( 'http' => array(
              'method' => 'POST',
              'header'  => 'Content-length: '. strlen( $txtXML ) . PHP_EOL .
              'Content-type: application/atom+xml' . PHP_EOL . 
              'Authorization: Bearer ' . trim( $accessToken2v3 ) . PHP_EOL .
              '',
              'content' => http_build_query( $post_data )
              )
          )
 );

 $response = file_get_contents( $url, false, $context );