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.
Related
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.
I'm in the process of trying to better understand http, more specifically I want to get comfortable working with web based APIs. Some of the documentation I've read for specific API's mention that the API will expect to get an http request in exactly this format, with specific headers and content.
I'm trying to use php cURL, but googling around I haven't found a way (that I understand) simply print my http request to the screen or a text file rather than sending it. I want to make sure that the request I'm constructing looks how I intend it to, rather than just getting back a success or failure message from whatever server the request is sent to. Is there an easy way to do this?
You should try using Fiddler. Fiddler show RESPONSE and REQUEST HEADER. Other than that you can install some extension to your browser that shows HEADER, Firefox does have such extension I think it is called LiveHTTP... sorry didn't remember name.
For web debugging Fiddler is what you need http://fiddler2.com/
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
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.
Hello i have iphone app now i want to send request or data to server or PHP file.
Please note: the php file is on another server not on the same server.
How can i send data to server using javascript ?
The fastest and easiest solution would be including jQuery and use it's post method; http://api.jquery.com/jQuery.post/