2017-12-27 143 views
1

我試圖購買Lending club二級市場票據,並且不斷收到「內部服務器錯誤」。我也曾多次要求借助俱樂部支持,但他們無能爲力。我也嘗試過這個帖子,但沒有運氣LendingClub.com API 500 Error for Buying Notes on Secondary MarketLendingClub.com API內部服務器在二級市場上購買票據的錯誤

請幫

<?php 
 
$invester_id = "516xxxxxx"; 
 
$api_key = "GVsZuxxxxxxxxx"; 
 
$ContentType = "application/json"; 
 
define("DEBUG_LENDING_API", true); 
 

 
$buy = buy_notes($invester_id, $api_key); 
 
print_r($buy);die; 
 

 
function buy_notes($invester_id, $api_key){ 
 
    $buy_notes_url = "https://api.lendingclub.com/api/investor/v1/accounts/$invester_id/trades/buy"; 
 
    $note = array("loanId" => "97277470", "orderId" => "139320895", "noteID" => "149206918", "bidPrice" => "19.45"); 
 
    $datas = array("aid" => "70654", "notes" => $note); 
 
    $buy_notes = call_curl($buy_notes_url, $api_key, json_encode($datas)); 
 
    $notes = json_decode($buy_notes['data']); 
 
    return $notes; 
 
    } 
 

 
function call_curl($url, $api_key, $post = "0"){ 
 
    $invester_id = "516xxxxxx"; 
 
    $ContentType = "application/json"; 
 
    $ch = curl_init(); 
 
    curl_setopt($ch, CURLOPT_URL, $url); 
 
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0"); 
 
    if($post != "0"){ 
 
    curl_setopt($ch,CURLOPT_POST, 1); 
 
    curl_setopt($ch,CURLOPT_POSTFIELDS, $post); 
 
    } 
 
    curl_setopt ($ch, CURLOPT_AUTOREFERER, true); 
 
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true); 
 
    $headers = array(); 
 
    $headers[] = "Authorization: $api_key"; 
 
    $headers[] = "Content-type: $ContentType"; 
 
    $headers[] = "Accept: $ContentType"; 
 
    $headers[] = "X-LC-Application-Key: $invester_id"; 
 
    //print_r(array_values($headers)); 
 
    //exit; 
 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
 
    $server_output = curl_exec ($ch); 
 
    echo $server_output. "<br>"; 
 
    exit; 
 
    $info = curl_getinfo($ch); 
 
    curl_close ($ch); 
 
    if(DEBUG_LENDING_API == true){ 
 
    return array("data" => $server_output, "response" => $info); 
 
    }else{ 
 
    return json_decode($server_output); 
 
    } 
 
    } 
 
?>

+1

你是從服務器上獲得500,還是他們的?我可以看到3個地方,你的代碼會在本地拋出500個地方,因爲'$ ContentType','$ invester_id'和'$ notes'沒有在函數範圍內定義。 – aynber

+1

這完全一樣。內部服務器錯誤返回HTTP狀態500. – aynber

+0

$ ContentType和$ invester_id已經在腳本的頂部定義。如果你向上滾動,你會看到它們。 $ notes被定義在$ notes = json_decode($ notes ['data']); – hdsouza

回答

1

我設法弄明白。我將「援助」設置爲$ invester_id,並最終做到了這一點。感謝Aynber爲你提供了一些提示。