2013-10-02 7 views
0

Google API를 통해 사용자로부터 모든 이메일을받는 데 cURL을 사용하고 있습니다. 다음은 https://developers.google.com/admin-sdk/email-audit/#retrieving_all_email_monitors_of_a_source_user입니다.CURL - get Google API에서 모든 이메일 검색

이 자습서에 따르면 서버는 '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); 

이 pls는 저에게 도움말을 가져 오는 코드를 무엇입니까?

+0

모든 이메일 모니터를 검색 할 때 어떤 결과가 나타 납니까? 거기서 만든 건가요? – Emily

+0

@EmilyLam : 모든 전자 메일 모니터에 대한 항목 요소가없는 AtomPub 피드를 반환합니다. –

답변

0

이 API의 URL로 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를 표시합니다. 그런 다음 코드를 사용하여 단일 요청의 결과를 가져올 수 있습니다.

+0

성공적으로 인증되었지만 응답에서 반환 데이터를 요청하지 않습니다. –

+0

작성 또는 가져 오기에 문제가 있는지 명확히 할 수 있습니까? –