我已经能够很好地向其他端点发出 API 请求,但是进行购买的端点似乎根本不起作用。看起来这是他们的服务器错误,但我想我会在这里问,以防万一我犯了一个粗心的错误。
我已经编写了多个版本的函数,但这是一个:
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);
}
这是他们的文档:
该子资源提供投资者账户的摘要。
操作:获取
网址:https ://api.lendingclub.com/api/investor/v1/accounts/[投资者 id]/trades/
URL 参数: 投资者 ID - 当用户登录时,可以从 Lending Club 网站上的账户摘要部分获得。
查询参数:无。
支持的格式:购买备注的 JSON 请求
请求/响应标头: 名称 类型 NULLABLE 描述 Aid String 否 合作伙伴代表其请求购买一张或多张票据的投资者 ID Array 否 一张或多张票据的数组 loanId String 否 其贷款的数字标识符note requested for purchase orderId String 否 票据订单的数字标识符 noteId String 否 票据的数字标识符 bidPrice String 否 正数值,以美元 ($) 和美分表示票据所需的购买价格 示例请求:JSON —< /p>
{ "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}
] }
示例响应—</p>
{ 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 pendingAccruedInterest: null :null yieldToMaturity:null executionStatus:[1] 0:“SUCCESS_PENDING_SETTLEMENT”}}
这就是我在 Postman POSTing 数据中测试时发生的情况:
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
提前致谢!