我试图在PHP中为Authy运行一个演示。我已经在Composer中安装了Authy库,所以现在我可以使用以下硬编码值注册用户:
$authy_api = new Authy\AuthyApi('<TESTING API KEY>', 'http://sandbox-api.authy.com'); // actual key omitted -- using the key generated for testing, not the one for production
$user = $authy_api->registerUser('something@something.com', '999-999-9999', 30); // actual credentials omitted
if($user->ok()){
echo "Success!";
$id = $user->id();
echo($id);
}当上面的脚本运行时,一个5位数字的用户id确实被生成了,所以一切看起来都很顺利,但是短信从来没有发送到我的手机。
一个可能的问题是,我的电话号码已经注册为应用程序电话(与管理帐户相关联),因此,由于每个电话号码(按文档)必须唯一地标识用户,也许我的号码已经为这个应用程序注册了,因此不需要发送新的令牌。如果是这种情况,则用户对象的id可以是先前注册的id。
然而,问题仍然存在于其他电话号码上。所以现在我迷路了。
发布于 2015-11-07 16:01:58
结果,代码本身并没有什么问题。
它只是沙箱API并没有真正通过发送短信。它只是为了测试目的而模拟这个过程,因此身份验证流程与生产API相同。
当我切换到生产API URL和密钥时,我能够接收到手机上的短信。
发布于 2015-11-02 16:54:47
盖斯刷
有两件事导致了你短信的短缺。
https://docs.authy.com/totp.html#requesting-sms-codes
然而,这种行为可以被覆盖。
所以你的最终代码是;
$authy_api = new Authy\AuthyApi('<TESTING API KEY>', 'http://sandbox-api.authy.com'); // actual key omitted -- using the key generated for testing, not the one for production
$user = $authy_api->registerUser('something@something.com', '999-999-9999', 30); // actual credentials omitted
if($user->ok()){
echo "Success!";
$id = $user->id();
echo($id);
// Now send SMS, force sending a message even if the user has the Authy mobile app installed
$sms = $authy_api->requestSms('authy-id', array("force" => "true")); }西蒙
发布于 2016-07-19 07:00:00
$authy_api = new AuthyApi(AUTHY_API_KEY, "https://api.authy.com");
$user = $authy_api->registerUser($email, $phone_number, $country_code); //// Register User
if($user->ok()) {
$sms = $authy_api->requestSms($user->id()); //// Send SMS
return $sms->ok();
}https://stackoverflow.com/questions/33446773
复制相似问题