2015-02-07 4 views
0

eBay API에 대한 GetItemTransactions 호출을 시도합니다. 이 호출은 기본적으로 정상적으로 작동하지만 마지막 트랜잭션 (itemID) 만 반환합니다.eBay API - 마지막 itemID 만 반환하는 cURL_multi

동일한 URL ($ url)을 사용하고 있기 때문에 내 cURL 구문에 오류가 있다고 생각합니다. 코드는 다음과 같습니다.

$mh = curl_multi_init(); 
$handles = array(); 

$i = 0; 

$urls = array("https://api.ebay.com/ws/api.dll", 
       "https://api.ebay.com/ws/api.dll", 
       "https://api.ebay.com/ws/api.dll"); 

foreach ($urls as $url) 
{ 
$handles[$url] = curl_init($url); 

curl_setopt($handles[$url], CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($handles[$url], CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($handles[$url], CURLOPT_HTTPHEADER, $headers); 
curl_setopt($handles[$url], CURLOPT_POST, 1); 
curl_setopt($handles[$url], CURLOPT_POSTFIELDS, $xml_request[$i]); 
curl_setopt($handles[$url], CURLOPT_RETURNTRANSFER, true); 

curl_multi_add_handle($mh, $handles[$url]); 

$i++; 

} 

$ headers (그들은 어쨌든 같습니다) 및 $ xml_request 변수가 올바르게 전송됩니다. 나는 $ handles [$ url]이 각 루프에서 동일하기 때문에 덮어 쓰여진다고 가정합니다.

답변

0

내가 비슷한 질문에서 답을 찾을 수/여기에 대답 :

여기

Can I execute a multiple parallel cURL against the same URL?

새로운 작업 코드 :

$mh = curl_multi_init(); 
$handles = array(); 

$i = 0; 

$url = "https://api.ebay.com/ws/api.dll"; 

$stationIds = array(207,303,305); 

foreach ($stationIds as $stationId) 
{ 

$handles[$stationId] = curl_init(); 
curl_setopt($handles[$stationId], CURLOPT_URL, $url); 

curl_setopt($handles[$stationId], CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($handles[$stationId], CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($handles[$stationId], CURLOPT_HTTPHEADER, $headers); 
curl_setopt($handles[$stationId], CURLOPT_POST, 1); 
curl_setopt($handles[$stationId], CURLOPT_POSTFIELDS, $xml_request[$i]); 
curl_setopt($handles[$stationId], CURLOPT_RETURNTRANSFER, true); 
curl_setopt($handles[$stationId], CURLOPT_FORBID_REUSE,1); 
curl_setopt($handles[$stationId], CURLOPT_FRESH_CONNECT,1); 

curl_multi_add_handle($mh, $handles[$stationId]); 

$i++; 

} 

참고 : 당신이 $ stationIds의 수를 조정해야 보내는 항목 수. eBay는 최대 18 개의 병렬 API 호출을 허용합니다.