Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Read request parameters
- $username= $_REQUEST["username"];
- $password = $_REQUEST["password"];
- // Store values in an array
- $returnValue = array("username"=>$username, "password"=>$password);
- // Send back request in JSON format
- echo json_encode($returnValue);
- ?>
- func getPHPJson() {
- let urlPath: String = "LINK_TO_PHP_FILE?username=(user)&password=(pass)"
- let url: NSURL = NSURL(string: urlPath)!
- let request1: NSMutableURLRequest = NSMutableURLRequest(URL: url)
- request1.HTTPMethod = "GET"
- let queue:NSOperationQueue = NSOperationQueue()
- NSURLConnection.sendAsynchronousRequest(request1, queue: queue, completionHandler:{ (response: NSURLResponse?, data: NSData?, error: NSError?) -> Void in
- do {
- if let jsonResult = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? NSDictionary {
- print(jsonResult)
- //print(jsonResult["isUser"] as! Bool)
- let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
- print("raw response: (responseString!)")
- }
- } catch let error as NSError {
- print(error.localizedDescription)
- print("error")
- let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
- print("raw response: (responseString)")
- }
- })
- }
- }
- {
- password = iosappusettest1;
- username = iosappusettest;
- }
- raw response: {"username":"iosappusettest","password":"iosappusettest1"}
- function authentication ($user, $pass){
- global $wp, $wp_rewrite, $wp_the_query, $wp_query;
- if(empty($user) || empty($pass)){
- return 0;
- } else {
- require_once('../wp-blog-header.php');
- $status = 0;
- $auth = wp_authenticate($user, $pass );
- if( is_wp_error($auth) ) {
- $status = 0;
- } else {
- $status = 1;
- }
- return $status;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement