function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
OIOI 

Error calling PHP file

Hello Everyone,

I am trying to call a php file using Apex class. I am attaching the Visual Force page and Apex class code and I am getting the following error " <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>502 Bad Gateway</title> </head><body> <h1>Bad Gateway</h1> <p>The proxy server received an invalid response from an upstream server.<br /> </p> </body></html> ". Any help is greatly appreciated.

 

<apex:page sidebar="false" controller="WebServ"> <apex:form > <apex:outputText value="{!Details}"></apex:outputText> </apex:form> </apex:page> public class WebServ { //The following example illustrates how you can use an authorization header with a request, and handle the response: public String getDetails() { Http http = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint('http://localhost/crm/accounts_mysql_tutorial.php'); req.setMethod('GET'); HttpResponse res = http.send(req); // Log the XML content System.debug(res.getBody()); return res.getBody(); } }

 

 

Thanks

Sue

Message Edited by OI on 02-17-2009 05:37 AM
werewolfwerewolf

Seriously?

 

req.setEndpoint('http://localhost/crm/accounts_mysql_tutorial.php');

 

You're trying to set the endpoint to localhost.  That will try to point the Apex server at itself, which obviously won't work.  Try pointing it at a web-accessible PHP page.