0

when I use file_get_contents function I get Failed to open stream: HTTP request failed! HTTP/1.1 502 Bad Gateway in xammp/...

$name = $_GET['name'];
$phone = $_GET['phone'];
$price = $_GET['price'];
$residue = $_GET['residue'];

file_get_contents("http://example.com:8080/?apikey=***********=&pid=*********&fnum=*******&tnum=$phone&p1=name&p2=price&p3=residue&v1=$name&v2=$price&v3=$residue");
1
  • Fix your http://example.com:8080, not this code Commented Sep 28, 2022 at 13:08

1 Answer 1

0

Failed to open stream means the target file was not located. Either the server responded with a 404 HTTP Status or the file is missing.

Use the proper URL Ensure your API Keys are still valid with server you're requesting to.


You can copy the URL to a browser and see the response from there.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you When I sent $name to the API, it was sent with a space, that's why I had this problem.
welcome. Always try some URL in your browser when PHP fails to return more detailed errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.