2016-06-06 1 views
1

에있는 사용자 프로필 사진을 얻으려고합니다. [버전 2013].PHP CURL을 사용하여 Exchange 서버에서 사용자 사진 가져 오기

나는 URL [예] 이하로 사용하여 사진을 볼 수 있습니다

https://companydomain.com/owa/service.svc/s/GetPersonaPhoto?email=user1%40companydomain.com&size=HR96x96&sc=1464941029314

요구 사항 :

폴더에 다운로드 된 모든 기업 사용자의 프로필 사진을 얻을 수 있습니다.

지금까지 무엇을 했습니까?

PHP는 CURL

<?php 
    $user = '[email protected]'; 
    $password = 'XXXXXXX'; 
    $fullurl="https://companydomain.com/owa/service.svc/s/GetPersonaPhoto?email=user1%40companydomain.com&size=HR96x96&sc=1464941029314"; 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_VERBOSE, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
    curl_setopt($ch, CURLOPT_FAILONERROR, 0); 
    curl_setopt($ch, CURLOPT_USERPWD, "$user:$password"); 
    curl_setopt($ch, CURLOPT_URL, $fullurl); 
    $returned = curl_exec($ch); 
    curl_close ($ch); 

출력을 사용하여 스크립트를 작성 : 페이지가 포함 : 개체 여기로 옮겼습니다.을 텍스트로 입력하고 "여기"링크를 클릭하면 Microsoft Outlook의 로그인 페이지로 이동합니다.

제가 원하는 것을 얻고 제가 빠진 것을 알려주도록 도와주세요. 사전에

덕분에

+0

이 사람이 날을 제안 시겠어요 얻을해야합니까? – SamJ

답변

0

당신이 제출하지의 URL에서 (301 또는 302) 리디렉션 것으로 보인다. 나는 솔루션을 제공 할 수 있으며, 필요한 "Image"가 될 "대상"-URL을 제공합니다.

function get_web_page($url) 
{ 
    $options = array( 
     CURLOPT_RETURNTRANSFER => true,  // return web page 
     CURLOPT_HEADER   => true, // return headers 
     CURLOPT_FOLLOWLOCATION => true,  // follow redirects 
     CURLOPT_ENCODING  => "",  // handle all encodings 
     CURLOPT_USERAGENT  => "boss", // who am i 
     CURLOPT_AUTOREFERER => true,  // set referer on redirect 
     CURLOPT_CONNECTTIMEOUT => 120,  // timeout on connect 
     CURLOPT_TIMEOUT  => 120,  // timeout on response 
     CURLOPT_MAXREDIRS  => 10,  // stop after 10 redirects 
    ); 

    $ch  = curl_init($url); 
    curl_setopt_array($ch, $options); 
    $content = curl_exec($ch); 
    $err  = curl_errno($ch); 
    $errmsg = curl_error($ch); 
    $header = curl_getinfo($ch); 
    curl_close($ch); 

    //$header['errno'] = $err; 
    // $header['errmsg'] = $errmsg; 
    //$header['content'] = $content; 
    print($header[0]); 
    return $header; 
} 
$thisurl = "http://www.example.com/redirectfrom"; 
$myUrlInfo = get_web_page($thisurl); 
echo $myUrlInfo["url"]; 

당신은 지금 http://www.example.com/redirectto

관련 문제