Now Hiring: Are you a driven and motivated 1st Line IT Support Engineer?

Send Single Message – PHP Integration

Send Single Message – PHP Integration

  • </pre>
    <pre class="prettyprint prettyprinted"><span class="kwd">try</span> <span class="pun">{</span>
        <span class="com">// Send a message using the primary device.</span><span class="pln">
        $msg </span><span class="pun">=</span><span class="pln"> sendSingleMessage</span><span class="pun">(</span><span class="str">"+11234567890"</span><span class="pun">,</span> <span class="str">"This is a test of single message."</span><span class="pun">);</span>
    
        <span class="com">// Send a message using the Device ID 1.</span><span class="pln">
        $msg </span><span class="pun">=</span><span class="pln"> sendSingleMessage</span><span class="pun">(</span><span class="str">"+11234567890"</span><span class="pun">,</span> <span class="str">"This is a test of single message."</span><span class="pun">,</span> <span class="lit">1</span><span class="pun">);</span>
        
        <span class="com">// Send a prioritize message using Device ID 1 for purpose of sending OTP, message reply etc…</span><span class="pln">
        $msg </span><span class="pun">=</span><span class="pln"> sendSingleMessage</span><span class="pun">(</span><span class="str">"+11234567890"</span><span class="pun">,</span> <span class="str">"This is a test of single message."</span><span class="pun">,</span> <span class="lit">1</span><span class="pun">,</span> <span class="kwd">null</span><span class="pun">,</span> <span class="kwd">false</span><span class="pun">,</span> <span class="kwd">null</span><span class="pun">,</span> <span class="kwd">true</span><span class="pun">);</span>
        
        <span class="com">// Send a MMS message with image using the Device ID 1.</span><span class="pln">
        $attachments </span><span class="pun">=</span> <span class="str">"https://example.com/images/footer-logo.png,https://example.com/downloads/sms-gateway/images/section/create-chat-bot.png"</span><span class="pun">;</span><span class="pln">
        $msg </span><span class="pun">=</span><span class="pln"> sendSingleMessage</span><span class="pun">(</span><span class="str">"+11234567890"</span><span class="pun">,</span> <span class="str">"This is a test of single message."</span><span class="pun">,</span> <span class="lit">1</span><span class="pun">,</span> <span class="kwd">null</span><span class="pun">,</span> <span class="kwd">true</span><span class="pun">,</span><span class="pln"> $attachments</span><span class="pun">);</span>
    	
        <span class="com">// Send a message using the SIM in slot 1 of Device ID 1 (Represented as "1|0").</span>
        <span class="com">// SIM slot is an index so the index of the first SIM is 0 and the index of the second SIM is 1.</span>
        <span class="com">// In this example, 1 represents Device ID and 0 represents SIM slot index.</span><span class="pln">
        $msg </span><span class="pun">=</span><span class="pln"> sendSingleMessage</span><span class="pun">(</span><span class="str">"+11234567890"</span><span class="pun">,</span> <span class="str">"This is a test of single message."</span><span class="pun">,</span> <span class="str">"1|0"</span><span class="pun">);</span>
    
        <span class="com">// Send scheduled message using the primary device.</span><span class="pln">
        $msg </span><span class="pun">=</span><span class="pln"> sendSingleMessage</span><span class="pun">(</span><span class="str">"+11234567890"</span><span class="pun">,</span> <span class="str">"This is a test of schedule feature."</span><span class="pun">,</span> <span class="kwd">null</span><span class="pun">,</span><span class="pln"> strtotime</span><span class="pun">(</span><span class="str">"+2 minutes"</span><span class="pun">));</span><span class="pln">
        print_r</span><span class="pun">(</span><span class="pln">$msg</span><span class="pun">);</span><span class="pln">
    
        echo </span><span class="str">"Successfully sent a message."</span><span class="pun">;</span>
    <span class="pun">}</span> <span class="kwd">catch</span> <span class="pun">(</span><span class="typ">Exception</span><span class="pln"> $e</span><span class="pun">)</span> <span class="pun">{</span><span class="pln">
        echo $e</span><span class="pun">-></span><span class="pln">getMessage</span><span class="pun">();</span>
    <span class="pun">}</span></pre>
    <pre>

Leave your thought here

Your email address will not be published.