本文主要是介绍展览展会行业怎么利用PHP接口给客户发送短信,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
随着网络时代的快速发展,展览展会行业作为企业交流与合作的重要平台,其信息传递的准确性和广泛性显得尤为重要。在这个信息爆炸的时代,如何有效地将展会信息传递给目标受众,成为参展商和主办方亟需解决的问题。而短信平台,作为一种低成本、高效的营销手段,正逐步成为展览展会行业推广的新宠。
支持免费对接试用乐讯通PaaS平台 找好用的短信平台,选择乐讯通,短信群发|短信平台|群发短信软件|群发短信平台|乐讯通PaaS平台http://yun.loktong.com/login/register/0c61bafb77
<?php
header("Content-type: text/html; charset=utf-8");
/*
文字短信发送demo
视频短信、弹屏闪信、语音短信、国际短信模板发送与文字短信类似
*/
$action='sendtemplate';
$url = 'http://www.lokapi.cn/smsUTF8.aspx';
$username = '******';
$password =strtoupper(md5('*****'));
$token = '*******';
$templateid = '******';
$param = '17712345678|张三|1230';
$timestamp = getMillisecond();
$sign = strtoupper(md5('action='.$action.'&username='.$username.'&password='.$password.'&token='.$token.'×tamp='.$timestamp));
$postData = array('action'=>$action,'username'=>$username, 'password'=>$password, 'token'=>$token, 'timestamp'=>$timestamp,'sign'=>$sign,'rece'=>'json','templateid'=>$templateid,'param'=>$param);$result= postSMS($url,$postData);echo $result;function postSMS($url,$postData)
{$row = parse_url($url);$host = $row['host'];$port = isset($row['port']) ? $row['port']:80;$file = $row['path'];$post = "";while (list($k,$v) = each($postData)) {$post .= rawurlencode($k)."=".rawurlencode($v)."&"; }$post = substr( $post , 0 , -1 );$len = strlen($post);$fp = @fsockopen( $host ,$port, $errno, $errstr, 10);if (!$fp) {return "$errstr ($errno)\n";} else {$receive = '';$out = "POST $file HTTP/1.1\r\n";$out .= "Host: $host\r\n";$out .= "Content-type: application/x-www-form-urlencoded\r\n";$out .= "Connection: Close\r\n";$out .= "Content-Length: $len\r\n\r\n";$out .= $post; fwrite($fp, $out);while (!feof($fp)) {$receive .= fgets($fp, 128);}fclose($fp);$receive = explode("\r\n\r\n",$receive);unset($receive[0]);return implode("",$receive);}
}function getMillisecond() {list($t1, $t2) = explode(' ', microtime());return (float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);}
?>
这篇关于展览展会行业怎么利用PHP接口给客户发送短信的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!