在android中使用json调用php函数时,响应为null
我正在尝试在magento中对android应用程序的用户进行身份验证。但是响应为null。 在php方面:在android中使用json调用php函数时,响应为null,php,android,json,magento,Php,Android,Json,Magento,我正在尝试在magento中对android应用程序的用户进行身份验证。但是响应为null。 在php方面: <?php require_once('http://carinopharmacy.com/Mage.php'); //Path to Magento umask(0); Mage::app(); $id = 1; try{ $result = Mage::getModel('customer/customer')->setWebsiteId($id)->
<?php
require_once('http://carinopharmacy.com/Mage.php'); //Path to Magento
umask(0); Mage::app();
$id = 1;
try{ $result = Mage::getModel('customer/customer')->setWebsiteId($id)->authenticate($email, $password); }catch( Exception $e ){ $result = false; }
?>
什么是
$email,$password
?它们是在哪里定义的?这是一个内置的函数,具有参数email和password。脚本中$email,$password
的值是什么?没有赋值。我不是php人。是否有必要定义变量?在调用该方法时不是替换了值。这是编程基础。如果未定义变量,如何获取其值?
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
JSONObject request=new JSONObject();
JSONObject json_response=null;
HttpClient client=new DefaultHttpClient();
HttpPost httppost=new HttpPost(Login_url);
try
{
request.put("email", email_text);
request.put("password", password_text);
HttpResponse response;
StringEntity entity=new StringEntity(request.toString());
httppost.addHeader("content-type","application/json");
response=client.execute(httppost);
String response_string=EntityUtils.toString(response.getEntity(),HTTP.UTF_8);
if (response_string.equals("true")) {
startActivity(new Intent(Login_activity.this, Main_activity.class));
}
else {
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Toast.makeText(Login_activity.this, "Email and password do not match", Toast.LENGTH_LONG).show();
}
});
}
}
catch(Exception e)
{
e.printStackTrace();
}
return null;
}