Advertisement
Guest User

Untitled

a guest
Jul 15th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. <?php
  2. // Read request parameters
  3. $username= $_REQUEST["username"];
  4. $password = $_REQUEST["password"];
  5. // Store values in an array
  6. $returnValue = array("username"=>$username, "password"=>$password);
  7. // Send back request in JSON format
  8. echo json_encode($returnValue);
  9. ?>
  10.  
  11. func getPHPJson() {
  12.  
  13. let urlPath: String = "LINK_TO_PHP_FILE?username=(user)&password=(pass)"
  14. let url: NSURL = NSURL(string: urlPath)!
  15. let request1: NSMutableURLRequest = NSMutableURLRequest(URL: url)
  16.  
  17. request1.HTTPMethod = "GET"
  18. let queue:NSOperationQueue = NSOperationQueue()
  19.  
  20. NSURLConnection.sendAsynchronousRequest(request1, queue: queue, completionHandler:{ (response: NSURLResponse?, data: NSData?, error: NSError?) -> Void in
  21.  
  22. do {
  23. if let jsonResult = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? NSDictionary {
  24. print(jsonResult)
  25. //print(jsonResult["isUser"] as! Bool)
  26. let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
  27. print("raw response: (responseString!)")
  28. }
  29. } catch let error as NSError {
  30. print(error.localizedDescription)
  31. print("error")
  32. let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
  33. print("raw response: (responseString)")
  34. }
  35. })
  36. }
  37. }
  38.  
  39. {
  40. password = iosappusettest1;
  41. username = iosappusettest;
  42. }
  43. raw response: {"username":"iosappusettest","password":"iosappusettest1"}
  44.  
  45. function authentication ($user, $pass){
  46. global $wp, $wp_rewrite, $wp_the_query, $wp_query;
  47.  
  48. if(empty($user) || empty($pass)){
  49. return 0;
  50. } else {
  51. require_once('../wp-blog-header.php');
  52. $status = 0;
  53. $auth = wp_authenticate($user, $pass );
  54. if( is_wp_error($auth) ) {
  55. $status = 0;
  56. } else {
  57. $status = 1;
  58. }
  59. return $status;
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement