{"id":417,"date":"2016-08-22T20:04:40","date_gmt":"2016-08-22T14:34:40","guid":{"rendered":"https:\/\/www.smsgatewaycenter.com\/blog\/?p=417"},"modified":"2026-07-20T12:30:54","modified_gmt":"2026-07-20T07:00:54","slug":"use-newline-sms-message-sending-via-http-sms-api","status":"publish","type":"post","link":"https:\/\/www.smsgatewaycenter.com\/blog\/use-newline-sms-message-sending-via-http-sms-api\/","title":{"rendered":"How to Use Newline in SMS Message When Sending via HTTP SMS API"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">We have been receiving the lot of enquiries to insert newline in the SMS message while sending SMS using <strong><a href=\"https:\/\/www.smsgatewaycenter.com\/blog\/send-sms-api-guide\/\">HTTP SMS API<\/a><\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So today, we have decided to post some sample code using PHP CURL method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PHP CURL Sample code as follow:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$target_url = 'https:\/\/enterprise.smsgatewaycenter.com\/SMSApi\/rest\/send';\n$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\";\n\n\/\/single number api\n$post = array(\n'userId' =&gt; 'myusername',\n'password' =&gt; 'xxxxxxx',\n'sendMethod' =&gt; 'simpleMsg',\n'msgType' =&gt; \"text\",\n'format' =&gt; \"json\",\n'mobile' =&gt; \"98xxxxxxxx\",\n'msg' =&gt; $msg,\n'senderId' =&gt; \"SGCSMS\");\n\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL, $target_url);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_HEADER, 0);\ncurl_setopt($ch, CURLOPT_VERBOSE, 0);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $post);\n$result = curl_exec($ch);\ncurl_close($ch);\necho $result;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Message on Phone Screenshot:<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"418\" src=\"https:\/\/www.smsgatewaycenter.com\/blog\/wp-content\/uploads\/2016\/08\/message-response.jpg\" alt=\"Message Response\" class=\"wp-image-421\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>Frequently Asked Questions on this topic:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Should I urlEncode the post data?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">CURLOPT_POST v\/s <strong>CURLOPT_POSTFIELDS<\/strong><\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>CURLOPT_POST<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">TRUE, to do a regular HTTP POST. This POST is the normal application\/x-www-form-urlencoded kind, most commonly used by HTML forms.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>CURLOPT_POSTFIELDS<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The full data to post in an HTTP &#8220;POST&#8221; 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 &#8216;;type=mimetype&#8217;. This parameter can either be passed as a urlencoded string like &#8216;para1=val1&amp;para2=val2&amp;&#8230;&#8217; 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">More info <a href=\"https:\/\/stackoverflow.com\/a\/10002620\/4306705\">here<\/a><\/p>\n<\/blockquote>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"517\" src=\"https:\/\/www.smsgatewaycenter.com\/blog\/wp-content\/uploads\/2016\/08\/http_sms_api_newline.jpg\" alt=\"HTTPS SMS api newline\" class=\"wp-image-420\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><br>Hope this helps to many of our clients and our visitors. Feel free to comment on anything.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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: Message on Phone Screenshot: Frequently Asked Questions on this topic: Should I urlEncode [&hellip;]<\/p>\n","protected":false},"author":118,"featured_media":420,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[268],"tags":[269,270,158],"class_list":["post-417","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-http-sms-api","tag-php-curl","tag-sms-message"],"_links":{"self":[{"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/posts\/417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/users\/118"}],"replies":[{"embeddable":true,"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/comments?post=417"}],"version-history":[{"count":0,"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/posts\/417\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/media\/420"}],"wp:attachment":[{"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/media?parent=417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/categories?post=417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.smsgatewaycenter.com\/blog\/wp-json\/wp\/v2\/tags?post=417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}