Application works differently via php's curl than direct
This probably wont make any sense, but that's why I'm here. I've inherited a web site that I'm trying to more "features" like Frankenstein needs a second left arm.
Part of the application makes about 10 different API calls to various service providers across the nation to get quotes. It does this by generating several different URLs and using mcurl to GET them in parallel. None of these return any html, they each query a single API and update the database.
It takes a few seconds to run, spinning its wheels as it makes the API queries, but nothing in the database is updated. I can see in the logs each of the URLs that was requested. If I take one of these urls, and put it in the address bar of a browser, it works just fine. The api is called and the database is updated.
Wait, there's more! In order to debug these individual scripts (since they have no output) I use fwrite(). This works when I use a URL in the address bar of a browser, but nothing is written then all scripts are executed via mcurl. (multi-curl_execute() to be precise.)
In short, when开发者_JS百科 php uses curl to execute a script, it won't update the mysql database, and it won't allow me to fopen a file. These do work if I cut/paste the GET request from the logs into a browser's address bar.
Now this software has been in production for a while on the live site, and works for them as expected. I'm doing development on my local machine, and this is where it's failing. It's just got to be something very simple.
--Dave
It has to be something in the HTTP headers that get sent with the request.
If you have access to the code of the web services (isn't mentioned in your post), you could dump the headers on that side, write it to a file or email it, and see the distinction between the mcurl call and the browser call.
The $_SERVER
array contains them with their names prepended with "HTTP".
Another idea is eavesdropping it on the client-side, from where mcurl or the browser are coming from, although I'm frankly not sure how you'd go about doing that without sniffing the network.
精彩评论