2011-10-27 4 views
3

PHP 스크립트를 사용하여 iContact에서 내 계정의 연락처 목록을 가져 오려고합니다. Resters를 사용하여 연락처 목록을 가져올 수 있습니다. 헤더, URL 및 일련 번호를 입력하여 이동하면 헤더와 URL이 올바른지 확인할 수 있습니다.php curl을 사용하여 icontact에서 연락처를 가져 오는 방법은 무엇입니까?

Response: 


Code: 
Array ([url] => https://app.sandbox.icontact.com/icp/a/412608/c/123920/contacts [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.094 [namelookup_time] => 0 [connect_time] => 0.094 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0) 
: 이것은 넣어 출력을 제공

<?php 

    $Headers = array(
       "Accept: text/xml", 
       "Content-Type: text/xml", 
       "API-Version: 2.2", 
       "API-AppId: grBddgWuirhAYT41K6gvrvRGaUGJFVQL", 
       "API-Username: <removed>", 
       "API-Password: <removed>"); 

    $Url = "https://app.sandbox.icontact.com/icp/a/412608/c/123920/contacts"; 

    $Handle = curl_init(); 
    if(!$Handle) 
    { 
     die("Could not create a cURL handle."); 
    } 

    curl_setopt($Handle, CURLOPT_URL, $Url); 
    curl_setopt($Handle, CURLOPT_HTTPHEADER, $Headers); 
    curl_setopt($Handle, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110303 Ubuntu/10.04 (lucid) Firefox/3.6.15"); 

    curl_setopt($Handle, CURLOPT_RETURNTRANSFER, true); 
    $Response = curl_exec($Handle); 

    $iCode = curl_getinfo($Handle); 
    echo "Response: <br />"; 
    print_r($Response); 
    echo "<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />"; 
    echo "Code: <br />"; 
    print_r($iCode); 

    curl_close($Handle); 
?> 

: 나는 (내 계정과 AP 세부 사항) 것을 실행할 때 iContact 내가 다음 코드를 실행할 때와 같은 응답을받을 그러나이 작업에 대한 예제 코드를 제공합니다

curl (현재는 그리 많지 않음)을 이해하면 http_code는 200이어야하고 xml은 $ Response에 있어야합니다.

아무도 내가 잘못하고있는 것을 지적 할 수 있습니까?

iContact 예는 여기있다 : 나는 get_contacts.php가해야 할 일을하려고 http://developer.icontact.com/documentation/code-library-zip-file/

.

답변

3

문제는 코드가 아니므로 괜찮습니다. 공용 서버를 사용해야했지만 내 localhost에서 응답을 얻지 못했습니다.

관련 문제