PHP Post

Here a quick example of how-to post some data over the web in a simple php script.

<?php
$datastream = array(
'short_msg'=&gt;'this is a simple message',
'address'=&gt;'98887996662',
);
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, <a href="http://psms.canoe-inc.com/send_sms" class="moz-txt-link-rfc2396E">"http://psms.canoe-inc.com/send_sms"</a>);
$o="";
foreach ($datastream as $k=&gt;$v)
{
$o.= "$k=".utf8_encode($v)."&amp;";
}
$post_data=substr($o,0,-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);

Leave a Reply

You must be logged in to post a comment.