title: SWIFT and PHP exchange with JSON
body: <p>iam using swift function to send POST query to php script</p>
  
  <pre><code>func post_retJSON_inJSON(params : Dictionary&lt;String, String&gt;,tourl:String)
      {
          let myUrl = NSURL(string: tourl);
          let request = NSMutableURLRequest(URL:myUrl!);
          request.HTTPMethod = "POST";
  
          var err: NSError?
          request.HTTPBody =  NSJSONSerialization.dataWithJSONObject(params, options: nil, error: &amp;err)
  
          request.addValue("application/json", forHTTPHeaderField: "Content-Type")
          request.addValue("application/json", forHTTPHeaderField: "Accept")
  
  
          let task = NSURLSession.sharedSession().dataTaskWithRequest(request)
              {
              data, response, error in
  
              if error != nil
              {
                  println("error=\(error)")
                  return
              }
  
              // You can print out response object
              println("response = \(response)")
  
              // Print out response body
              let responseString = NSString(data: data, encoding: NSUTF8StringEncoding)
              println("responseString = \(responseString)")
  
              //Let's convert response sent from a server side script to a NSDictionary object:
  
              var err: NSError?
              var myJSON = NSJSONSerialization.JSONObjectWithData(data, options: .MutableLeaves, error:&amp;err) as? NSDictionary
  
              if let parseJSON = myJSON {
                  // Now we can access value of First Name by its key
                  var firstNameValue = parseJSON["firstName"] as? String
                  println("firstNameValue: \(firstNameValue)")
              }
  
              UIApplication.sharedApplication().networkActivityIndicatorVisible = false
  
          }
  
          task.resume()
          UIApplication.sharedApplication().networkActivityIndicatorVisible = true
      }
  </code></pre>
  
  <p>With this php</p>
  
  <pre><code>$firstName= $_POST["firstName"];
  $lastName = $_POST["lastName"]; 
  
  $returnValue = array("firstName"=&gt;$firstName, "lastName"=&gt;$lastName);
  
  // Send back request in JSON format
  echo json_encode($returnValue);
  </code></pre>
  
  <p>AND then in swift i have a response </p>
  
  <pre><code>Optional({"firstName":null,"lastName":null})
  </code></pre>
  
  <p>I think i already try everything but  I cant get in PHP parametres sended by SWIFT query. Help me please to figureout it!!!</p>