我是使用 PHP cURL 的初学者,并且正在尝试使用使用 oAuth 的 Box.com API 2.0。我正在尝试返回有关用户的基本信息。这是我的代码:
$box_1 = curl_init("https://api.box.com/2.0/users/me");
curl_setopt($box_1, CURLOPT_HTTPHEADER, "Authorization: Bearer token_was_here");
curl_setopt($box_1, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($box_1, CURLOPT_POSTFIELDS, "fields=id,name,login");
$box_curl1 = curl_exec($box_1);
curl_close($box_1);
当我运行这个时,我得到这个错误:{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value 'fields=id,name,login'. Entity body should be a correctly nested resource attribute name\/value pair"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Bad Request","request_id":"request_id_was_here"}
当我删除第 4 行时,我根本没有得到任何回应。