<!-- our URL for creating a new Text message --> <?php $url = 'http://api.v4.swiftreach.com/api/Messages/Text/Create'; $authToken = '123456'; $jsonString = ' { "SMSCode":0, "Name":"API SMS", "Description":"created by api 22", "FromName":"SwiftAPI", "FromAddress":"alerts@swiftreach.com", "DefaultSpokenLanguage":"English", "Body":[{ "SpokenLanguage":"English", "Subject":"my subject", "Body":[{ "$type":"SwiftReach.Swift911.Core.Messages.SMS.SMS_TEXT_SOURCE_TEXT, SwiftReach.Swift911.Core", "Text":"this is the body of my sms", "TextType":0 }] }], "ReplyType":0, "ReplyCriteria":null, "ReplyWindow":0, "ReplyConfirmation":null, "Visibility":0, "DeleteLocked":false }'; $headers = array( 'Content-type: application/json', 'SwiftAPI-Key: ' . $authToken, 'Accept: application/json', 'Expect:' ); $ch = curl_init(); $args = array( CURLOPT_URL => $url, CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $jsonString, CURLOPT_HTTPHEADER => $headers, ); curl_setopt_array($ch, $args); $res = curl_exec($ch); $res_data = json_decode($res, true); print($res_data); ?> <!-- example return value --> 123456