Sample call in PHP

To call Say5 API from a remote php script you need to have either curl or socket functions compiled into php installation on your server.

Sample function to use curl for connection:

function say5req($request,$host,$port,$protocol,$user,$accesshash)
{
	if(is_array($request))
		$request = serialize($request);
	$post = 'user='.$user.'&access='.$accesshash.'&request='.base64_encode($request);
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "${protocol}://${host}:${port}/api");
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	$data=curl_exec ($ch);
	curl_close ($ch);
	return($data);
}

Sample call to Say5 api using above function:

$host = '1.2.3.4';
$port = 30;
$protocol = 'http';

$user = 'root';
$accesshash = '
kGlOWa01r3ZnWpsW3aUwBFebFjKyZdasHsHOUZW1lbFhrxVWXzZldZkVVGVWTdnw
VdZaXtTRaF2VwRdVXabSMEVXMpFVlQaFrWFVbjFb4vZ0nVFXTTScRdeUYRbNbWBR
YO9SzVpGSVYWFNZWYZcWzSb1ZlQbaMlm2RlaWgdlTZJVn2VmesNZOVxVtahFRrVr
51VZUUJhQlWUl1Ndb0rVWyMJktVUVJ4NlVW1mihFXcsaFVbSYY1UFaVcSJ0VNdyk
YXmcwVZUYsad4322VFA5VkJaFVdXVVImFEVW4aVWVMEFVMnJJxhVeFhZVIUGwnV0
XYUslU82EmXk1VWJqwe234FcpMiVaYV2UWZVJaV54VVdVVNUbxZSYXBUZSUm1Rac
O0Z0mYYWnrFd5OGkSSGZnckGUa4ndUgoNyZdVVasd987IUYd97777sdh2a2JioVW
WlZWkZOSlmtVzcXR2UWnWGJmvGXkW2lZH2t5ZR1E2km9RJcm61aZV0RXzZjVAVkV';

$request = 'command=SuspendAccount&user_name=user1';

$result = say5req( $request, $host, $port, $protocol, $user, $accesshash );

print $result;

Request can also be sent as an array, for example:

$host = '1.2.3.4';
$port = 30;
$protocol = 'http';

$user = 'root';
$accesshash = '
kGlOWa01r3ZnWpsW3aUwBFebFjKyZdasHsHOUZW1lbFhrxVWXzZldZkVVGVWTdnw
VdZaXtTRaF2VwRdVXabSMEVXMpFVlQaFrWFVbjFb4vZ0nVFXTTScRdeUYRbNbWBR
YO9SzVpGSVYWFNZWYZcWzSb1ZlQbaMlm2RlaWgdlTZJVn2VmesNZOVxVtahFRrVr
51VZUUJhQlWUl1Ndb0rVWyMJktVUVJ4NlVW1mihFXcsaFVbSYY1UFaVcSJ0VNdyk
YXmcwVZUYsad4322VFA5VkJaFVdXVVImFEVW4aVWVMEFVMnJJxhVeFhZVIUGwnV0
XYUslU82EmXk1VWJqwe234FcpMiVaYV2UWZVJaV54VVdVVNUbxZSYXBUZSUm1Rac
O0Z0mYYWnrFd5OGkSSGZnckGUa4ndUgoNyZdVVasd987IUYd97777sdh2a2JioVW
WlZWkZOSlmtVzcXR2UWnWGJmvGXkW2lZH2t5ZR1E2km9RJcm61aZV0RXzZjVAVkV';

$request = array('command'=>'SuspendAccount', 'user_name'=>'user1');;

$result = say5req( $request, $host, $port, $protocol, $user, $accesshash );

print $result;
 
 
Copyright 2007-2019 Say5 Inc.