備注:2009年12月9日移動飛信升級造成影響的 sms.api.bz 免費發送短信API接口,已于12月14日恢復正常。
飛信
是由中國移動通信集團公司推出的一款集商務應用和娛樂功能為一體的,基于手機應用以及與Internet深度互通的即時通訊產品,可免費給好友發送短信。
1、下載中國移動飛信PC客戶端軟件(
http://www.fetion.com.cn/downloads/pc.aspx
),并注冊開通飛信。注冊成為飛信用戶,下載飛信PC客戶端、使用PC客戶端基本功能,不收取費用。
2、通過PC客戶端,邀請并添加免費短信接收方的手機號碼(僅限中國移動)到您的飛信好友,該手機號需要通過通過PC客戶端、或回復短信接受您的邀請;
3、通過
http://sms.api.bz/
提供的 API 接口,即可免費給飛信好友或給你自己的手機發短信。利用本API接口可進行日程提醒、服務器監控、報警、故障通知或短信自動控制等功能。
飛信免費發短信API接口在線演示頁面:
http://sms.api.bz/
https://sms.api.bz/
(HTTPS加密接口)
飛信免費發短信API接口調用方式(通過HTTP訪問以下網址、支持GET和POST):
注:短信內容最大長度為180個漢字,超過180個漢字不發送。返回的信息為UTF-8編碼的中文文本信息。
2009年5月28日新增:
飛信免費發短信API接口調用方式(通過HTTPS加密隧道訪問以下網址、支持GET和POST,進一步保證您的密碼安全):
注:短信內容最大長度為180個漢字,超過180個漢字不發送。返回的信息為UTF-8編碼的中文文本信息。
例1:在Linux命令行下通過curl命令給自己的手機號(假設為13800138000)發送短信(HTTP GET 方式)
例2:在PHP5中通過file_get_contents函數發送短信(HTTP GET 方式)
- <?php ??
- $url ?=? "http://sms.api.bz/fetion.php?username=13812345678&password=123456&sendto=13512345678&message=短信內容" ; ??
- $result ?=? file_get_contents ( $url ); ??
- echo ? $result ;? //返回信息默認為UTF-8編碼的漢字,如果你的頁面編碼為gb2312,請使用下行語句輸出返回信息。 ??
- //echo?iconv("UTF-8",?"GBK",?$result); ??
- ?>??
例3:在PHP中通過curl發送短信(HTTP POST 方式)
- <?php ??
- $data [ "username" ]?=?13812345678; ??
- $data [ "password" ]?=? "password123" ; ??
- $data [ "sendto" ]?=?13512345678; ??
- $data [ "message" ]?=? "這是一條測試短信!" ; ??
- ??
- $curl ?=? new ?Curl_Class(); ??
- $result ?=?@ $curl ->post( "http://sms.api.bz/fetion.php" ,? $data ); ??
- echo ? $result ;? //返回信息默認為UTF-8編碼的漢字,如果你的頁面編碼為gb2312,請使用下行語句輸出返回信息。 ??
- //echo?iconv("UTF-8",?"GBK",?$result); ??
- ??
- //curl類 ??
- class ?Curl_Class ??
- { ??
- ???? function ?Curl_Class() ??
- ????{ ??
- ???????? return ?true; ??
- ????} ??
- ??
- ???? function ?execute( $method ,? $url ,? $fields ?=? '' ,? $userAgent ?=? '' ,? $httpHeaders ?=? '' ,? $username ?=? '' ,? $password ?=? '' ) ??
- ????{ ??
- ???????? $ch ?=?Curl_Class::create(); ??
- ???????? if ?(false?===? $ch ) ??
- ????????{ ??
- ???????????? return ?false; ??
- ????????} ??
- ??
- ???????? if ?( is_string ( $url )?&&? strlen ( $url )) ??
- ????????{ ??
- ???????????? $ret ?=?curl_setopt( $ch ,?CURLOPT_URL,? $url ); ??
- ????????} ??
- ???????? else ??
- ????????{ ??
- ???????????? return ?false; ??
- ????????} ??
- ???????? //是否顯示頭部信息 ??
- ????????curl_setopt( $ch ,?CURLOPT_HEADER,?false); ??
- ???????? // ??
- ????????curl_setopt( $ch ,?CURLOPT_RETURNTRANSFER,?true); ??
- ??
- ???????? if ?( $username ?!=? '' ) ??
- ????????{ ??
- ????????????curl_setopt( $ch ,?CURLOPT_USERPWD,? $username ?.? ':' ?.? $password ); ??
- ????????} ??
- ??
- ???????? $method ?=? strtolower ( $method ); ??
- ???????? if ?( 'post' ?==? $method ) ??
- ????????{ ??
- ????????????curl_setopt( $ch ,?CURLOPT_POST,?true); ??
- ???????????? if ?( is_array ( $fields )) ??
- ????????????{ ??
- ???????????????? $sets ?=? array (); ??
- ???????????????? foreach ?( $fields ?AS? $key ?=>? $val ) ??
- ????????????????{ ??
- ???????????????????? $sets []?=? $key ?.? '=' ?.?urlencode( $val ); ??
- ????????????????} ??
- ???????????????? $fields ?=?implode( '&' , $sets ); ??
- ????????????} ??
- ????????????curl_setopt( $ch ,?CURLOPT_POSTFIELDS,? $fields ); ??
- ????????} ??
- ???????? else ? if ?( 'put' ?==? $method ) ??
- ????????{ ??
- ????????????curl_setopt( $ch ,?CURLOPT_PUT,?true); ??
- ????????} ??
- ??
- ???????? //curl_setopt($ch,?CURLOPT_PROGRESS,?true); ??
- ???????? //curl_setopt($ch,?CURLOPT_VERBOSE,?true); ??
- ???????? //curl_setopt($ch,?CURLOPT_MUTE,?false); ??
- ????????curl_setopt( $ch ,?CURLOPT_TIMEOUT,?10); //設置curl超時秒數 ??
- ??
- ???????? if ?( strlen ( $userAgent )) ??
- ????????{ ??
- ????????????curl_setopt( $ch ,?CURLOPT_USERAGENT,? $userAgent ); ??
- ????????} ??
- ??
- ???????? if ?( is_array ( $httpHeaders )) ??
- ????????{ ??
- ????????????curl_setopt( $ch ,?CURLOPT_HTTPHEADER,? $httpHeaders ); ??
- ????????} ??
- ??
- ???????? $ret ?=?curl_exec( $ch ); ??
- ??
- ???????? if ?(curl_errno( $ch )) ??
- ????????{ ??
- ????????????curl_close( $ch ); ??
- ???????????? return ? array (curl_error( $ch ),?curl_errno( $ch )); ??
- ????????} ??
- ???????? else ??
- ????????{ ??
- ????????????curl_close( $ch ); ??
- ???????????? if ?(! is_string ( $ret )?||?! strlen ( $ret )) ??
- ????????????{ ??
- ???????????????? return ?false; ??
- ????????????} ??
- ???????????? return ? $ret ; ??
- ????????} ??
- ????} ??
- ??
- ???? function ?post( $url ,? $fields ,? $userAgent ?=? '' ,? $httpHeaders ?=? '' ,? $username ?=? '' ,? $password ?=? '' ) ??
- ????{ ??
- ???????? $ret ?=?Curl_Class::execute( 'POST' ,? $url ,? $fields ,? $userAgent ,? $httpHeaders ,? $username ,? $password ); ??
- ???????? if ?(false?===? $ret ) ??
- ????????{ ??
- ???????????? return ?false; ??
- ????????} ??
- ??
- ???????? if ?( is_array ( $ret )) ??
- ????????{ ??
- ???????????? return ?false; ??
- ????????} ??
- ???????? return ? $ret ; ??
- ????} ??
- ??
- ???? function ?get( $url ,? $userAgent ?=? '' ,? $httpHeaders ?=? '' ,? $username ?=? '' ,? $password ?=? '' ) ??
- ????{ ??
- ???????? $ret ?=?Curl_Class::execute( 'GET' ,? $url ,? '' ,? $userAgent ,? $httpHeaders ,? $username ,? $password ); ??
- ???????? if ?(false?===? $ret ) ??
- ????????{ ??
- ???????????? return ?false; ??
- ????????} ??
- ??
- ???????? if ?( is_array ( $ret )) ??
- ????????{ ??
- ???????????? return ?false; ??
- ????????} ??
- ???????? return ? $ret ; ??
- ????} ??
- ??
- ???? function ?create() ??
- ????{ ??
- ???????? $ch ?=?null; ??
- ???????? if ?(!function_exists( 'curl_init' )) ??
- ????????{ ??
- ???????????? return ?false; ??
- ????????} ??
- ???????? $ch ?=?curl_init(); ??
- ???????? if ?(! is_resource ( $ch )) ??
- ????????{ ??
- ???????????? return ?false; ??
- ????????} ??
- ???????? return ? $ch ; ??
- ????} ??
- ??
- } ??
- ?>??
備注:9日移動飛信升級造成影響的 sms.api.bz 免費發送短信API接口,已于2009年12月14日恢復正常。
2009年12月9日中國移動飛信服務器升級,變更了登錄地址和部分協議。升級后的協議無法直接給接收方手機號(tel)發送短信,只能給飛信號(sip uri)、自己的手機號發送短信。本人通過重新抓包,對飛信協議進行分析,修改了sms.api.bz接口代碼,通過將接收方手機號(tel)轉換為user-id,再通過user-id轉換為飛信號(sip uri),進行短信發送,一切OK。
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
