这是从命令行使用的curl,如果启用了 curl,您可以将其更改为 php 文件。
<?php
// add your access token
$access_token = "your_access_token";
$data = array('site_id' => 'MLA');
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL,"https://api.mercadolibre.com/users/test_user?access_token=$access_token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
$response = curl_exec($ch);
// json response
echo $response;
您可以使用json_decode() 将json $response 转换为数组并处理数据
样本输出
{
"id": 123456,
"nickname": "TT123456",
"password": "qatest123456",
"site_status": "active",
"email": "test@test.com"
}