高手在民间,PHP - pecl_http简单可用的短信验证码快速接入代码:

在现在,短信验证码应用非常广泛,但是要想快速高效的接入并调试好,还是非常耗费时间的,由于市场的短信服务商太多,一家家的对比考察非常耗时间,下面分享一个我用过且非常稳定的一个短信接口作为演示示例:
`
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://vip.veesing.com/smsAp...');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append(new http\QueryString(array(
'appId' => '41KYR0EB**',
'appKey' => 'IIWCKKSR7NOQ**',
'phone' => '1561894**',
'templateId' => '1043',
'variables' => '1234')));$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

`
以上就是PHP - pecl_http接入短信验证码的示例,希望以上的分享,可以提升大家的工作效率,有需要的复制粘贴拿走去用吧!

PHP - pecl_http.php和文档说明下载

你可能感兴趣的:(php,https,安全,http)