PHP- Call a querystring with json answer

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$x&license=$x&email=$x

How can I do this?
Ingo FoersterProgrammerAsked:
Who is Participating?
Dave BaldwinFixer of ProblemsCommented:
file_get_contents should do it.
$newdata = file_get_contents('$x&license=$x&email=$x');
echo $homepage;

Open in new window

Ray PaseurCommented:
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).
Ingo FoersterProgrammerAuthor Commented:
Works great.
Dave BaldwinFixer of ProblemsCommented:
Glad to help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.