2016-04-26 68 views

回答

2

我想你需要的東西是這樣的:

<?php 

     $url = "https://api.url.com/v1/market/total-items.json"; 
     $page = "/v1/market/total-items.json"; 
     $headers = array( 
      "POST ".$page." HTTP/1.0", 
      "Authorization: Bearer oVi4yPxk1bJ64Y2qOsLJ2D2ZlC3FpK4L" 
     ); 

     $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_URL,$url); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 

     $data = curl_exec($ch); 
+0

不顯示任何內容:( http://horrorlab.com /envato/ttt.php – pskkar

+1

當然,它沒有顯示任何內容,我沒有在這個腳本中輸出任何東西,它只是將結果存儲在'$ data'中,您可以添加'echo $ data;'來查看響應 – Ahmad

+0

謝謝男人!現在正在工作:) – pskkar

1

可以從github上branch這裏生成的PHP代碼爲您的捲曲的命令。以下是爲您的請求生成的一個:

<?php 
$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL, "https://api.url.com/v1/market/total-items.json"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); 


$headers = array(); 
$headers[] = "Authorization: Bearer oVi4yPxk1bJ64Y2qOsLJ2D2ZlC3FpK4L"; 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 

$result = curl_exec($ch); 
if (curl_errno($ch)) { 
    echo 'Error:' . curl_error($ch); 
} 
curl_close ($ch); 
+0

什麼都沒顯示:( http://horrorlab.com/envato/newv.php – pskkar