Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中使用md5使用密钥和密码获取rest调用时出错?_Android_Md5 - Fatal编程技术网

在android中使用md5使用密钥和密码获取rest调用时出错?

在android中使用md5使用密钥和密码获取rest调用时出错?,android,md5,Android,Md5,如何在android中使用md5使用密钥和密码进行rest调用? 但我在loginService方法中得到一个错误作为响应 错误: {状态:错误,消息:签名不匹配} 我遵循的步骤, 步骤1-我创建了一个字符串参数,用于使用md5string方法获取哈希字符串 步骤2-调用loginService方法从web服务获取响应 呼叫代码: { String param = "name" + first_name + last_name + "email" + email + "faceboo

如何在android中使用md5使用密钥和密码进行rest调用? 但我在loginService方法中得到一个错误作为响应

错误: {状态:错误,消息:签名不匹配}

我遵循的步骤, 步骤1-我创建了一个字符串参数,用于使用md5string方法获取哈希字符串 步骤2-调用loginService方法从web服务获取响应

呼叫代码:

{ 
    String param = "name" + first_name + last_name  + "email" + email + "facebook_user_id" + facebook_user_id + "location" + location + "zip_code" + zip_code + "birthday" + birthday + "time" + time + "api_key" + api_key;
    String signature = md5(param);
    Post_Method_Interface commonPost = new CommonPostMethod();
    getResponceForParse = commonPost.loginService(
                first_name + last_name, email,facebook_user_id, location, zip_code, birthday,time, api_key, signature);
    Log.d(">>> GetResponceForParse >>> ",getResponceForParse);

    if (!facebook_user_id.equals(null)) {
            Post_Method_Interface commonPost = new CommonPostMethod();
            getResponceForParse = commonPost
                                .FacebookLoginModel(first_name + last_name,
                                        email, facebook_user_id, location,
                                        zip_code, birthday, time, api_key,
                                        signature);
            Log.d("GetResponceForParse 1", getResponceForParse);
                        Intent i = new Intent(getApplicationContext(),
                                HomeActivity.class);

}
Post_方法_接口类的loginService web服务方法

public String loginService(String name, String email,
        String facebook_user_id, String location, String zip_code,
        String birthday, String timestamp, String api_key, String sig) {

    try {
        JSONObject schObject = new JSONObject();
        schObject.put("name", name);
        schObject.put("email", email);
        schObject.put("facebook_user_id", facebook_user_id);
        schObject.put("location", location);
        schObject.put("zip_code", zip_code);
        schObject.put("birthday", birthday);
        schObject.put("time", timestamp);
        schObject.put("api_key", api_key);
        schObject.put("sig", sig);
        String URL = ApiConstant.URL_FacebookLoginModel;
        JsonPostRequest postrequest = new JsonPostRequest();
        InputStream is = postrequest.doPost(schObject, URL);
        response = postrequest.inputSteamToString(is);
        Log.d("Login", response);
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
    return response;
}

md5方法:

private static final String md5(final String parem) {
try {
    // Create MD5 Hash
    MessageDigest digest = java.security.MessageDigest
            .getInstance("MD5");
    digest.update(parem.getBytes());
    byte messageDigest[] = digest.digest();

    // Create Hex String
    StringBuffer hexString = new StringBuffer();
    for (int i = 0; i < messageDigest.length; i++) {
        String h = Integer.toHexString(0xFF & messageDigest[i]);
        while (h.length() < 2)
            h = "0" + h;
        hexString.append(h);
    }
    return hexString.toString();
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
}
return "";
}

请帮助我,这是一个非常糟糕的时刻