教你如何使用网络免费发短信
bae吧
全部回复
仅看楼主
level 6
cplushua 楼主
这个网络特指BAE,bae很不错,请勿乱用。告诉大家如何使用,仅仅是为了给自己提供方便~~尤其是刚刚接触这个领域的童鞋们~~ 这里有代码可以直接复制一下。如果你不知道这个代码如何使用,建议还是不要使用的好了~~或者如果你喜欢看文档的话,文档里其实有用法。
接下来是代码。。。
2012年09月25日 15点09分 1
level 6
cplushua 楼主
<?php
/***************************************************************************
*
* Copyright (c) 2012 219.me, Inc. All Rights Reserved
*
*
**************************************************************************/
/**
* @file index.php
* @author CplusHua
* @date 2012-06-14
* @version v0.1
* @brief
*/
require_once 'Bcms.class.php';
$message=$_POST['msg'];
$tel=$_POST['tel'];
$key=$_POST['pwd'];
$address=Array(0=>$tel);
$address=json_encode($address);
print_r($address);
$accessKey = '';//AK
$secretKey = '';//SK
$queueName = '';//消息队列名
$host = 'bcms.api.duapp.com';
function error_output ( $str )
{
echo "\033[1;40;31m" . $str ."\033[0m" . "\n";
}
function right_output ( $str )
{
echo "\033[1;40;32m" . $str ."\033[0m" . "\n";
}
function sms ( $queueName, $message, $address )
{
global $accessKey, $secretKey, $host;
$bcms = new Bcms ( $accessKey, $secretKey, $host ) ;
$ret = $bcms->sms ( $queueName, $message, $address ) ;
if ( false === $ret )
{
error_output ( 'WRONG, ' . __FUNCTION__ . ' ERROR!!!!!' ) ;
error_output ( 'ERROR NUMBER: ' . $bcms->errno ( ) ) ;
error_output ( 'ERROR MESSAGE: ' . $bcms->errmsg ( ) ) ;
error_output ( 'REQUEST ID: ' . $bcms->getRequestId ( ) );
}
else
{
right_output ( 'SUCC, ' . __FUNCTION__ . ' OK!!!!!' ) ;
right_output ( 'result: ' . print_r ( $ret, true ) ) ;
}
}
function fetchMessage ( $queueName )
{
global $accessKey, $secretKey, $host;
$bcms = new Bcms ( $accessKey, $secretKey, $host ) ;
//$optional [ Bcms::MSG_ID ] = 1;
$optional [ Bcms::FETCH_NUM ] = 2;
$ret = $bcms->fetchMessage ( $queueName, $optional ) ;
if ( false === $ret )
{
error_output ( 'WRONG, ' . __FUNCTION__ . ' ERROR!!!!!' ) ;
error_output ( 'ERROR NUMBER: ' . $bcms->errno ( ) ) ;
error_output ( 'ERROR MESSAGE: ' . $bcms->errmsg ( ) ) ;
error_output ( 'REQUEST ID: ' . $bcms->getRequestId ( ) );
}
else
{
right_output ( 'SUCC, ' . __FUNCTION__ . ' OK!!!!!' ) ;
right_output ( 'result: ' . print_r ( $ret, true ) ) ;
}
}
if (''==$key)//设置简单认证密码
sms($queueName, $message, $address);

2012年09月25日 15点09分 2
level 1
只能发 不能接收回复吗?
2012年10月01日 15点10分 4
不能,消息队列才可以取消息
2012年10月21日 17点10分
level 6
cplushua 楼主
2012年11月02日 16点11分 5
level 6
cplushua 楼主
BAE关闭短信服务
2012年11月02日 16点11分 6
1