调用 GET Rest 时出现 403 错误 API

Getting 403 Error on Calling GET Rest API

根据 API 文档,Curl 是:

curl -X GET "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=110001&date=31-03-2021" -H "accept: application/json" -H "Accept-Language: hi_IN"

我的PHP脚本:

$url='https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode='.$pincode.'&date='.$tomorrow;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
    'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
    'Content-Type: application/json',
    'accept: application/json',
    'Accept-Language: hi_IN'
]);
$response = curl_exec($curl);
$curl_error = curl_errno($curl);
curl_close($curl);
echo $response . PHP_EOL;

当我 运行 我的 PHP 脚本时,我收到这个 403 错误:

我的 PHP 脚本有什么问题吗?

工作正常

<?php

    $pincode = "110001";
    $tomorrow = "31-03-2021";
    
    $url='https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode='.$pincode.'&date='.$tomorrow;
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, [
        'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
        'Content-Type: application/json',
        'accept: application/json',
        'Accept-Language: hi_IN'
    ]);
    $response = curl_exec($curl);
    $curl_error = curl_errno($curl);
    curl_close($curl);
    echo $response . PHP_EOL;

知道了..

{
  "centers": [
    
  ]
}