"$phoneNoRecip", 'Text'=>"$msgText"); if (($n1 != NULL) && ($v1 != NULL)) $postfields[$n1] = $v1; if (($n2 != NULL) && ($v2 != NULL)) $postfields[$n2] = $v2; if (($n3 != NULL) && ($v3 != NULL)) $postfields[$n3] = $v3; if (($n4 != NULL) && ($v4 != NULL)) $postfields[$n4] = $v4; if (($n5 != NULL) && ($v5 != NULL)) $postfields[$n5] = $v5; if (($n6 != NULL) && ($v6 != NULL)) $postfields[$n6] = $v6; if (($n7 != NULL) && ($v7 != NULL)) $postfields[$n7] = $v7; if (($n8 != NULL) && ($v8 != NULL)) $postfields[$n8] = $v8; if (($n9 != NULL) && ($v9 != NULL)) $postfields[$n9] = $v9; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $hostUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); // TODO: This script does not currently validate SSL Certificates // curl_setopt($ch, CURLOPT_VERBOSE, true); // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); // curl_setopt($ch, CURLOPT_CAINFO, 'cacert.pem'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // change to 1 to verify cert curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); $result = curl_exec($ch); return $result; } // This code provides an example of how you would call the SendSMS function from within // a PHP script to send a message. // The response from the NowSMS server is echoed back from the script. $x = SendSMS('https://sample.smshosts.com/', 'username', 'password', '+44999999999', 'Test Message'); echo $x; // This example adds an additional URL parameter, ReceiptRequested=Yes $x = SendSMS('https://sample.smshosts.com/', 'username', 'password', '+44999999999', 'Test Message with delivery report', 'ReceiptRequested', 'Yes'); echo $x; ?>