2016-09-30 51 views
0

我有一個連接使用捲曲(最新版本),以我們的API(IIS)服務器的站點。我的解決方案正在爲WAMP和XAMPP,但越來越細的問題在IIS問題上獲取數據後用IIS捲曲

我沒能獲得API服務器上發佈數據。

//代碼段

$客戶=新的HttpClient();

$client->setAdapter('Zend\Http\Client\Adapter\Curl'); 

    $url = (isset($apiUrl) && $apiUrl != NULL) ? $apiUrl : CustomConstantsFunction::apiCommunityUrl(); 
    $client->setUri($url); 

    $headers = $client->getRequest()->getHeaders(); 
    $headers->addHeaderLine('Authorization', \Application\Functions\CustomConstantsFunction::encryptDecrypt('encrypt',$host.'-ZendCommunityProduct-'.$todayTimestamp)); 

    $client->setMethod('POST'); 

    $client->setParameterPOST($postData); 

    $client->setHeaders($headers); 
    $client->setOptions(array(
     'maxredirects' => 1, 
     'timeout'  => 300, 
     'curloptions' => array(
      CURLOPT_HEADER => 1, 
      CURLOPT_RETURNTRANSFER => true, 
      CURLOPT_SSL_VERIFYHOST => false, 
      CURLOPT_UNRESTRICTED_AUTH => TRUE, 
      CURLOPT_SSL_VERIFYPEER => FALSE, 
     ) 
    )); 
    $response = $client->send(); 
    $response = $response->getBody(); 
    $data = json_decode($response);   
    return $data; 

我也嘗試cURL'ing不同的網站,他們返回的內容很好,但他們對我沒有幫助。

有其他人遇到這個錯誤,知道周圍的工作?

謝謝:)

回答

0

請嘗試以下API網址

$url = (isset($apiUrl) && $apiUrl != NULL) ? $apiUrl."/" : CustomConstantsFunction::apiCommunityUrl(); 

也改變$客戶setOptions參數。

$client->setOptions(array(
     'maxredirects' => 2, 
     'timeout'  => 300 
    )); 

它爲我工作。 :)