Welcome to the SMS Gateway Center Blog!

Access our blog to gain knowledge about the newest developments and expert recommendations for bulk SMS, voice call services, and WhatsApp Business API usage. The blog features content ranging from marketing strategies and latest industry news to technical guides and product announcements. We provide the resources you need to optimize your communication strategies and learn about our platform's latest features.

Explore professional advice and step-by-step guides alongside relevant case studies to boost your audience reach and interaction. Begin your search now and discover how SMS Gateway Center can strengthen your business communication system.

How to Use Newline in SMS Message When Sending via HTTP SMS API

We have been receiving the lot of enquiries to insert newline in the SMS message while sending SMS using HTTP SMS API.

So today, we have decided to post some sample code using PHP CURL method.

PHP CURL Sample code as follow:

<?php
$target_url = 'https://enterprise.smsgatewaycenter.com/SMSApi/rest/send';
$msg = "Hello Oscar,\r\nYour order dated 22/08/2016\r\nAmount INR 5000 Cash On Delivery\r\nYour Package will be delivered by tomorrow between 3PM to 7PM.\r\nRegards SMSGatewayCenter.com";

//single number api
$post = array(
'userId' => 'myusername',
'password' => 'xxxxxxx',
'sendMethod' => 'simpleMsg',
'msgType' => "text",
'format' => "json",
'mobile' => "98xxxxxxxx",
'msg' => $msg,
'senderId' => "SGCSMS");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
curl_close($ch);
echo $result;

Message on Phone Screenshot:

Message Response

Frequently Asked Questions on this topic:

Should I urlEncode the post data?

If you are using CURL post method, then CURL will encode the data for you. You just need to use raw field data into the fields array and then initiate the call. If you use the data as an array then the data will be automatically urlencoded by CURL and, if at all passed as a string, then you need to urlencode first before making the call.

CURLOPT_POST v/s CURLOPT_POSTFIELDS

CURLOPT_POST

TRUE, to do a regular HTTP POST. This POST is the normal application/x-www-form-urlencoded kind, most commonly used by HTML forms.

CURLOPT_POSTFIELDS

The full data to post in an HTTP “POST” operation. To post a file, prepend a filename with @ and use the full path. The filetype can be explicitly specified by following the filename with the type in the format ‘;type=mimetype’. This parameter can either be passed as a urlencoded string like ‘para1=val1&para2=val2&…’ or as an array with the field name as key and field data as value. If the value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, value must be an array if files are passed to this option with the @ prefix.

More info here

HTTPS SMS api newline


Hope this helps to many of our clients and our visitors. Feel free to comment on anything.

Save this interesting page on your favorite Social Media

Blog Author

SMS Gateway Center Desk

SMS Gateway Center is one of the largest and leading SMS Provider in India. It is run by a large professional team to cater small companies to large corporate companies. SMS Gateway Center is associated with the best operators in India covering the entire states in India. SMS Gateway Center has been serving through its SMS Resellers in more than 20 states in India. To become our SMS Reseller, kindly contact us

Looking for the best business communication solutions, get in touch!