Curl get data from php script without displaying it on that script

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Curl get data from php script without displaying it on that script



I have two php scripts on two different servers. I'm using curl to get data from one to the other (from server 1 to server 2):


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);

curl_close($ch);



It works but is there a way to hide the output on server 1 if somebody is accessing that script through its actual url?





Need to build the Authorization. So, when accessing the api from server 1, we need to provide an authentication.
– Khoa TruongDinh
Aug 12 at 16:02





Hey @KhoaTruongDinh, i was thinking to set a GET variable with a token in it but would that be oky? I mean i tested it and it works buuuut is there no other fancy way to do it? X_X
– emma
Aug 12 at 16:07





you probably want to do this via .htaccess with a deny all.
– Funk Forty Niner
Aug 12 at 16:11



.htaccess




2 Answers
2



A very basic way to lock down your PHP script is to create a password via a URL parameter. What if you had ?pwd=ABCDEF (create your own password here https://passwordsgenerator.net/) and then your Server-side PHP script can check to see if the password matches the URL parameter, and if it does you can print out the output.
Then modify PHP script #2 to pass your chosen password as a URL Parameter





thank you for taking time to answer to my question!:D I've done it, it works!
– emma
Aug 13 at 6:56





you are more than welcome
– Blank
Aug 14 at 5:04



May be you can use cookies.
Send a private cookie with curl and check on server 1 for that cookie and cookie value.
If that's not the right cookie, show error or set header to 404





I know not being able to comment under a question can be a bit frustrating at times, but I had to remove that in an edit. You started off right, but that rant shouldn't have been part of the answer. You can place a comment underneath your own post/answer. Just trying to help you out here.
– Funk Forty Niner
Aug 12 at 16:09





Btw, that downvote that you just got, isn't mine.
– Funk Forty Niner
Aug 12 at 16:10







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard