首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >android连接到php,用于向移动端发送登录验证码

android连接到php,用于向移动端发送登录验证码
EN

Stack Overflow用户
提问于 2014-03-06 14:35:07
回答 1查看 380关注 0票数 0

我正在开发一个用于登录website.In网站的安卓应用程序,每次检查用户名和密码后,一个验证码都会发送给用户,用于填写具有相同功能的登录page.In安卓应用程序的下一部分我能够检查用户名和password.But我不确定是否有可能触发发送验证码到mobile.Please的php代码告诉我这是可能的还是没有。

sndactivation_code.php

代码语言:javascript
复制
<?php
set_include_path("/home2/tradeni1/php");
require_once("HTTP/Request2.php");
if(!isset($_SESSION))
{
session_start();
}
if(isset($_REQUEST['user_id']))
{
$id=$_SESSION['uid'];
$sql=mysql_query("INSERT INTO code (`id` ,`code` ,`user_id` ,`status`) VALUES ('' , '', '$id','0')");
$lastid=mysql_insert_id();
$code=rand(100000,999999);//"stock_".$lastid;
$_SESSION['code']=$code;
$sql1=mysql_query("UPDATE code SET code = '$code' WHERE id='$lastid'");


$user_res = mysql_query("SELECT * FROM users WHERE id='$id'");
if(mysql_num_rows($user_res) == 0) {
    $user_res = mysql_query("SELECT * FROM subscribers where id='$id'");
}

$user_row = mysql_fetch_array($user_res);

$username = ucfirst($user_row['name']);
$phone = $user_row['mobile'];
$date = date("d M Y",time());
}

$message = "Dear " . $username . ", your one time login code for " . $date . " is " . $code;
$data = array(
    'username' => 'trdnif',
    'password' => 'trade123',
    'from' => 'TRDNIF',
    'to' => $phone,
    'udh' => "",
    'dlr-mask' => 19,
    'dlr-url' => "",
    'text' => $message
);

$request = new HTTP_Request2("http://myvaluefirst.com/smpp/sendsms", HTTP_Request2::METHOD_GET);
$url = $request->getUrl();
$url->setQueryVariables($data);
try {
    $response = $request->send();
    if (200 == $response->getStatus()) {
        //echo $response->getBody();
    } else {
        //echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . $response->getReasonPhrase();
        echo "";
    }
} catch (HTTP_Request2_Exception $e) {
    //echo 'Error: ' . $e->getMessage();
}

?>
EN

回答 1

Stack Overflow用户

发布于 2014-03-06 14:44:41

您需要在服务器端有一个端点,网站和应用程序都可以将用户名和密码发送到该端点,作为响应,它们将获得访问码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22216907

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档