在现在,短信验证码应用非常广泛,但是要想快速高效的接入并调试好,还是非常耗费时间的,由于市场的短信服务商太多,一家家的对比考察非常耗时间,下面分享一个我用过且非常稳定的一个短信接口作为演示示例:
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://vip.veesing.com/smsApi/verifyCode');
$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接入短信验证码的示例,希望以上的分享,可以提升大家的工作效率,有需要的复制粘贴拿走去用吧!
来源:oschina
链接:https://my.oschina.net/u/3937044/blog/4711194