【问题标题】:Call Async with multiple Http Post Method In Android在 Android 中使用多个 Http Post 方法调用异步
【发布时间】:2023-03-23 09:08:01
【问题描述】:

请求指导我了解android中的json解析,并且可以从直接url读取json对象,例如可以从http://api.androidhive.info/contacts/读取信息。

问题:- 我想使用 Async Http Post 方法调用 API 函数

方法:POST Api Key value 每次post验证 带参数验证登录帖子(如何带参数传递)

我的 API 代码是

if ( $_POST['api_key'] == 'abc1239op3rt'  ) 
{
    if( $_POST['action'] == 'verifylogin')
	{
			    if(trim($_POST['email']) == "") 
				{
				 echo json_encode( array('status' => 'failure', 'message' => 'Please enter email address. ') );
				 exit(0);
				}
				 elseif(trim($_POST['password']) == "") 
				{
				 echo json_encode( array('status' => 'failure', 'message' => 'Please enter password. ') );
				 exit(0);
				}
				
					else{

					$result = verifylogin(  $_POST['email'], $_POST['password'] );
					

					$status = ""; 
					if($result != false)
					{
						$data = $result;
						$message = "Login Successfully."; 
						$status = "success";
					}
					else
					{
						$data = $result;
						$message = "Error! Try again."; 
						$status = "failure"; 
					}
					echo json_encode( array('status' => $status, 'message' => $message,'data' => $data) );
					exit(0);
	}
		

	} 
}

【问题讨论】:

  • 这是安卓代码吗?
  • 这可能会有所帮助:danielnugent.blogspot.com/2015/06/…
  • 提供的一小段代码是 PHP 中的一个 API。我想通过 android Async Post Method 来阅读这个 API。在提供的代码中,1ST 必须通过 post 检查 API KEY,而不是函数(方法)传递参数。混淆多个 Post 如何使用异步方法处理。

标签: android


【解决方案1】:

如果我理解正确,您需要在请求中设置标题。去看看this link

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-26
    • 2022-10-15
    相关资源
    最近更新 更多