Executing JSON link in PHP and parsing the contents - php

json url :
http://www.nseindia.com/homepage/Indices1.json
I am able to get the json output whenever i am executing this link directly in my address bar of the browser.
When i try to use php file_get_contents() or using curl i am unable to retrieve json output from the above url in my php file on my website on another shared server.
using curl i get the following response :
Access Denied
You don't have permission to access "http://www.nseindia.com/homepage/Indices1.json" on this server.
I need to have that json data decoded using php in my application.

The site is blocking cURL requests. You could likely get around it by spoofing your user agent, but it'd be a bit rude to disrespect their clear desire not to have the JSON data scraped by other servers.

Related

How to send PDF file in json from PHP to ajax application

I have a PHP script which make a curl request to remote server and get PDF file in response. If I store this response to file it is correct PDF file. Now I need to send thid file to browser as json cause initial request was ajax from browser. But dont know how to do it.
The browser solution should be something like this https://stackoverflow.com/a/27563953/2092927 and I have it prepared. But I dont know how to send PDF from PHP as json. I know how to send it to download via common http request but dont know how to send it like json.
Does somebody know how to do it? Thanks for help.

Unable to execute PHP action via Postman

I am trying to write code to download files from a financial data website. The file is accessible and easily downloadable by clicking the page, but my goal is to be able to reach the file via a POST request, with what I could deduce from Chrome's inspector.
My request never seems to reach the downloadable zip file, I'm not certain how it is wrong, I probably missed something reading the html.
This is the page
This is the request I'm sending through Postman (POST):
http://www.histdata.com/get.php?tk=216a804365eccace285d20afed7acefe&date=2000&datemonth=2000&platform=ASCII&timeframe=M1&fxpair=EURUSD
POST is not going to work on a get.php url.
use something like CURL to read the file from an external web.

Use of an already created cookie to get content via php script

I have regular credentials to access a specific site (built with OpenCMS).
Everyday I download (Save AS) a bunch of pages, parse them and extract the data I need.
Is there a way to do it via PHP? Maybe using the cookie that's already been set?
Or passing credentials in http request? (I tried but seems OpenCMS won't allow that).
I've seen something about stream_context_create but I can't figure out how to do it.
Read up on CURL. You can specify a cookie jar to use, which means you can copy your normal browser cookies into the file CURL is using.

Send JSON Data to Browser but HIDE contents

I'm not sure if I'm getting this right, but I'll try to describe what I do. I've got a file with JSON data in it, which is needed for a synology package server, so if I add the url to the package server of the synology nas it accepts it as Package Server and reads the packages. This all depends on the JSON file and I need to set DirectoyIndex of my Apache to this JSON file to make it work. The Downside now is, everyone accessing this url with a browser can directly look into this JSON file.
Can I somehow wrap or hide this json data but still have it used by the NAS Package Server. IE using a index.php or index.html showing some kind of webpage but having the json data transferred too, when accessing the page?

Get files on PHP web service (SOAP)

I have .Net client that sends files.
How can i use PHP web service to get those files and return them after some changes back to client??
I didn't found code to GET those files, maybe someone have a code example...
You can send the file data encoded in Base64 from the client to your PHP web service, and handle them with the $_FILES superglobal. There is a similar topic here : PHP SOAP Transfering Files

Categories