2016-07-26 269 views
0

我已經能夠與其他終端進行API請求,但購買終端似乎根本不起作用。這似乎是一個服務器端錯誤,但我想我會問這裏,以防萬一我犯了一個粗心的錯誤。LendingClub.com用於在第二市場上購買備註的API 500錯誤

我寫我的功能的多個版本,但是這是一個:

function getLCInfo($endpoint, $getData = false) { 
    $api_url = "https://api.lendingclub.com/api/investor/"; 
    $verison = "v1"; 
    $account_id = "12345678"; 
    $ContentType = "application/json"; 

    $url = "$api_url$verison/accounts/$account_id/$endpoint/"; 

    if($getData) { 
    $url .= "?" . urldecode(http_build_query($getData)); 

    echo $url; 
    } 


    $key = "aaaaaaaaaaaaaaaa99999999"; 

    $ch = curl_init(); 

    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, 
       array('Authorization: ' . $key, 
        'Content-type: ' . $ContentType , 
        'Accept: ' . $ContentType, 
        'X-LC-Application-Key: ' . $account_id)); 

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); 
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); 
    $output = curl_exec($ch); 

    curl_close($ch); 

    return json_decode($output); 
} 

這是他們documentation

此子資源提供了投資者的帳戶的摘要。

操作:GET

網址:https://api.lendingclub.com/api/investor/v1/accounts/[investor ID] /供應商/

URL參數:投資者標識 - 這可以從借貸俱樂部網站上的賬戶 總結部分,當用戶登錄時獲得。

查詢參數:無。

支持的格式:對於購買須知JSON請求

請求/響應頭:NAME TYPE NULLABLE說明在代表其合作伙伴是 請求購買筆記的一個或多個音符投資者的 援助字符串否的ID數組號 或更多票據loanId字符串否 票據請求的貸款的數字標識orderId字符串否數字標識 票據的訂單noteId字符串票據的數字標識 bidPrice字符串否正數以美元($)和美分值表示買入價所需的用於音符樣本請求:JSON -

{  "aid":70654,"notes": [  {"loanId":3349795,"orderId":19979983,"noteId":5730626,"bidPrice":9.79}, 
    {"loanId":707414,"orderId":1369944,"noteId":4154191,"bidPrice":23.84}, 
    {"loanId":1076461,"orderId":2133757,"noteId":7827843,"bidPrice":34.45} 

] }

樣品應答爲

{  buyNoteConfirmations:  [ 3 ] :   {   loanId: 3349795   noteId: 5730626   bidPrice: 9.79 
     outstandingAccruedInterest: null   outstandingPrincipal: null 
     yieldToMaturity: null    executionStatus:   [ 1 ] : " 

NOTE_DOES_NOT_EXIST「} 1:{的LoanID:707414 noteId:4154191 bidPrice :23.84 outstandingAccruedInterest:null outstandingPrincipal:null yieldToMaturity:null executionStatus:[1]:「 NOTE_NOT_AVAILABLE」 } 2:{的LoanID:1076461 noteId:7827843 bidPrice:34.45 outstandingAccruedInterest:空outstandingPrincipal:空yieldToMaturity:空executionStatus:[1] 0: 「 SUCCESS_PENDING_SETTLEMENT」 }}

這是發生在我試驗郵差 發佈數據:

POST /api/investor/v1/accounts/87308218/trades/ HTTP/1.1 
Host: api.lendingclub.com 
Authorization: aaaaaaaaaaa111111 
Content-Type: application/json 
Cache-Control: no-cache 
Postman-Token: 68d283a6-08f0-6789-3542-3a1baa554ce7 

{ 
    "aid":70654,"notes": 
    [ 
     {"loanId":3349795,"orderId":19979983,"noteId":5730626,"bidPrice":9.79}, 
     {"loanId":707414,"orderId":1369944,"noteId":4154191,"bidPrice":23.84}, 
     {"loanId":1076461,"orderId":2133757,"noteId":7827843,"bidPrice":34.45} 
    ] 
} 

,我試圖用GET像他們的文件說。

GET /api/investor/v1/accounts/87308218/trades/?aid=12345678&notes[0][loanId]=17213188&notes[0][orderId]=25300948&notes[0][noteId]=48382917&notes[0][bidPrice]=6.77&notes[1][loanId]=17213188&notes[1][orderId]=25300943&notes[1][noteId]=48382538&notes[1][bidPrice]=6.77 HTTP/1.1 
Host: api.lendingclub.com 
Authorization: aaaaaaaaaaa111111 
Cache-Control: no-cache 
Postman-Token: b34cb60b-91ea-c82e-349f-d395b01b1dc0 

在此先感謝!

回答

0

我想通了!結果LendingClub在他們的文檔上有不正確的信息(超級沮喪!)。

我的解決方案是將操作更改爲POST而不是GET,並且端點不正確。

他們有網址:https://api.lendingclub.com/api/investor/v1/accounts/[investor ID] /貿易/,它應該是URL:https://api.lendingclub.com/api/investor/v1/accounts/ /交易/買 (這其實更有道理,因爲他們的API的銷售端點/供應商/銷售結束

我希望LendingClub的一些開發人員閱讀並編輯API文檔,我相信我並不孤單!

相關問題