Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void registerUser(final String username, final String email, final String password) {
- pDialog.setMessage("Signing Up...");
- pDialog.show();
- request = new StringRequest(Method.POST, SL_URL, new Response.Listener<String>() {
- @Override
- public void onResponse(String s) {
- pDialog.dismiss();
- String[] split = s.split("Config.php");
- String after = split[1];
- try {
- JSONObject jsonObject = new JSONObject(after);
- boolean error = jsonObject.getBoolean("error");
- if (error) {
- String errorMsg = jsonObject.getString("error_msg");
- Toast.makeText(getApplicationContext(),
- errorMsg, Toast.LENGTH_LONG).show();
- } else {
- session.setLogin(true, username, email);
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }) {
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- HashMap<String, String> hashMap = new HashMap<>();
- hashMap.put("tag", "login");
- hashMap.put("username", name);
- hashMap.put("password", password);
- return hashMap;
- }
- };
- queue.add(request);
- }
- let username = usernameTxt.text
- let password = passwordTxt.text
- let urlPath: String = "***"
- let url: NSURL = NSURL(string: urlPath)!
- let request1: NSMutableURLRequest = NSMutableURLRequest(URL: url)
- request1.HTTPMethod = "POST"
- let stringPost="tag=login&username=" + username! + "&password=" + password! // Key and Value
- NSLog(stringPost)
- let data = stringPost.dataUsingEncoding(NSUTF8StringEncoding)
- request1.timeoutInterval = 60
- request1.HTTPBody=data
- request1.HTTPShouldHandleCookies=false
- let queue:NSOperationQueue = NSOperationQueue()
- NSURLConnection.sendAsynchronousRequest(request1, queue: queue, completionHandler:{ (response: NSURLResponse?, data: NSData?, error: NSError?) -> Void in
- do {
- var jsonResult: NSDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
- } catch _ {}
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement