2016-07-21 228 views
0

我使用PHP執行卷曲請求的結果訪問卷曲請求+ PHP

{"success":"true","lead_id":"141872","code":201} 

OR 

{"error":true,"duplicate":true,"message":"Duplicate: This has already been submitted to the API.","code":400} 

如何訪問在$的數據結果只電流返回1

回答

1

將返回傳輸設置爲true以使頁面響應爲$結果

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
+0

工程100% - 謝謝。 –

0
$options = array (
    CURLOPT_CONNECTTIMEOUT => 1, // timeout on connect 
    CURLOPT_TIMEOUT => 1, // timeout on response 
    CURLOPT_MAXREDIRS => 1 , 
    CURLOPT_HTTPHEADER => array("REMOTE_ADDR: $proxy", "HTTP_X_FORWARDED_FOR: $proxy"), 
    CURLOPT_URL => $url 
    ); 
$ch = curl_init(); 
curl_setopt_array ($ch, $options); 
$result = curl_exec($ch); 
print_r($result); 
curl_close($ch); 

您的解決方案: