Link to home
Start Free TrialLog in
Avatar of Ingo Foerster
Ingo Foerster

asked on

PHP- Call a querystring with json answer

Hello,
on server 1 I have a PHP script with json output. I call this script with an querysting to get the result.
I want to call this PHP script from another PHP script by calling the commandline.
So I want to call from the PHP script of server one the script on server 2 by calling this

http://www.myserver.com/customscripts/insert.php?username=$x&license=$x&email=$x

How can I do this?
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If the PHP script responds to a GET request (ie, you can type all of the arguments you need into a browser address bar and "visit" the script to get the JSON string back in the browser) then Dave Baldwin's answer is the right way to go.  Note that he recommended the entire URL starting with http:// because you want the script to get processed through the web server.  This is not the same as reading the script locally.  If it gets parsed through the web server, PHP will be invoked and the script's output data will be returned.  If you read it locally, the script will be returned, not its output.

If you try Dave's solution and still have troubles, please post the PHP script that you're trying to call and we can look for an alternative method (probably cURL).
Avatar of Ingo Foerster
Ingo Foerster

ASKER

Works great.
Glad to help.