2016-07-26 213 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文档,我相信我并不孤单!