sc_webservice("Method", "URL", "Port", "Send Method", "Parameters Array", "Setting's Array", "Timeout", "Return")

This macro is used to communicate with a web service.

Parameter
Description
Method Informs what method will be used to access the web service. Ex: file_get_contents or curl.
URL URL used to access the web service.
Port Port used to access the web service.
Send Method Defines the request method of the web service. It can be GET ou POST.
Parameters Array Parameter's array used to access the web service, varying according to the accessed service.
Settings's Array(optional) Parameter's array for configuration of the access method used.
Timeout(optional) Service's access timeout.
Return(optional) Web service's return method. When it is set as "True", the return from the web service comes as an array, if it is set as "False" it will return as the original web service format. Default: True

 

 

$parms = array(
'METHOD' => 'GetBalance',
'RETURNALLCURRENCIES' => 1,
'VERSION' => urlencode(51.0),
'USER' => urlencode({paypal_api_login}),
'PWD' => urlencode({paypal_api_password}),
'SIGNATURE' => urlencode({paypal_api_key})
);
$parms = http_build_query($parms);

Ex1 - Using the macro file_get_contents:
sc_webservice('file_get_contents', $webservice_url, $_SERVER["SERVER_PORT"], "POST", $parms, array(), 30);

 

Ex2 - Using the macro with CURL:
$response = sc_webservice("curl", {paypal_type}, 80, "POST", $parms, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER=>false), 30);