1

Don't know whether this is the appropriate forum or not for this question. Below mentioned code was working fine till day before yesterday. But now showing Resource Not Found. But, if I open another new tab and copy paste the URL, results are showing. And then again if I run the code, it's showing the desired result. Can anyone dealing with NSE data, guide me in this regard.

<html>
<head><title>test</title></head>
<body>
<?php
$url = 'https://www.nseindia.com/api/corporates-pit?index=equities&from_date=21-06-2020&to_date=21-09-2020&symbol=JUSTDIAL';
$response = getJSONData($url);
print_r($response);
function getJsonData($url){
print_r($url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
print_r($result);
curl_close($ch);
$obj = json_decode($result,true);
return $obj;
}
?>
</body>
</html>
  • I've tried it from a browser and code, both show *Resource not found*. Do you have anything in the browser which may have logged into the site? – Nigel Ren Sep 21 '20 at 15:52
  • No. Nothing as such. If you keep https://www.nseindia.com/ opened in one tab and then try to open the url from another tab, it is working. Unable to understand what's happening. Might be cookies related stuffs. – Sagen Murmu Sep 21 '20 at 16:12
  • Please check the below solution post by VarunS2002: https://stackoverflow.com/a/64044088/6834734 – icharan Apr 18 '21 at 06:55

1 Answers1

2

NSE has implemented time based cookies for API. If you try to access API data you won't get it.

TradeMatic
  • 46
  • 2