0

这就是我想要做的

header('Content-Type: application/json');
$APP_ID= "application-id : xxxxxxxxxxxxxxxx";
$REST_KEY= "secret-key : xxxxxxxxxxxxxxx";
$APP_TYPE= "Content-Type:REST";
$POST = "POST";
$GET ="GET";
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $GET);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_HTTPHEADER, array($APP_ID, $REST_KEY, $APP_TYPE));
curl_setopt($curl, CURLOPT_URL, "http://api.backendless.com/test/data/items";);
$result = curl_exec( $curl );
curl_close( $curl );
$result = json_decode($result);
echo json_encode($result,JSON_PRETTY_PRINT);

作为回应,我得到了这个

{
"code": 2002,
"message": "Version is disabled or provided wrong application info (application id or secret key)"
}

所有的键和 ID 都是正确的,版本也可以工作

那有什么问题???为什么它不能正确吐出JSON结果?

更新版本 只需删除空格,如下所示

$APP_ID= "application-id: xxxxxxxxxxxxxxxx";
$REST_KEY= "secret-key: xxxxxxxxxxxxxxx";
4

0 回答 0