bae吧 关注:1,300贴子:8,157
  • 3回复贴,共1

教你如何使用网络免费发短信

取消只看楼主收藏回复

这个网络特指BAE,bae很不错,请勿乱用。告诉大家如何使用,仅仅是为了给自己提供方便~~尤其是刚刚接触这个领域的童鞋们~~ 这里有代码可以直接复制一下。如果你不知道这个代码如何使用,建议还是不要使用的好了~~或者如果你喜欢看文档的话,文档里其实有用法。
接下来是代码。。。


1楼2012-09-25 23:31回复
    <?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);
    


    2楼2012-09-25 23:31
    回复
      http://tieba.baidu.com/p/1943852857


      5楼2012-11-03 00:37
      回复
        BAE关闭短信服务


        6楼2012-11-03 00:37
        回复