Salesforce | How to access php code in salesforce apex class

Author - Webner
26.02.2016
|
0 Comments
||

We can access the php code in salesforce using @future(callout=true/false). The function we make for accessing the php code in apex class is of static type and does not return any value.

Syntax:

@future(callout=true)
public static void function_Name()
{
  //variable declaration
     try
     {
          Http h = new Http();
          HttpRequest req = new HttpRequest();
          HttpResponse res = new HttpResponse();
          req.setTimeout(60000);
          String url =”//Path for the php code”;
          req.setEndPoint(url);
          req.setMethod('GET');
          res = h.send(req);
          String response  = res.getBody();
    }
    catch(exception e)
    {
       system.debug('Save file to server exception :'+e);
    }
}

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *