日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php免费利用飞信发送验证码,PHP 使用飞信API发送免费短信示例

發(fā)布時間:2023/12/18 php 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php免费利用飞信发送验证码,PHP 使用飞信API发送免费短信示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

這篇文章主要為大家詳細介紹了PHP 使用飛信API發(fā)送免費短信示例,具有一定的參考價值,可以用來參考一下。

對PHP 使用飛信 API 來發(fā)送免費短信感興趣的小伙伴,下面一起跟隨512筆記的小編兩巴掌來看看吧!

/**

* PHP 使用飛信 API 來發(fā)送免費短信

*

* @param

* @arrange 512-筆記網(wǎng): 512PiC.com

**/

$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超時秒數(shù)

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;

}

}

/*** 來自512筆記(www.512pic.com) ***/

注:關于PHP 使用飛信API發(fā)送免費短信示例的內(nèi)容就先介紹到這里,更多相關文章的可以留意512筆記的其他信息。

關鍵詞:短信

您可能感興趣的文章

總結

以上是生活随笔為你收集整理的php免费利用飞信发送验证码,PHP 使用飞信API发送免费短信示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。