ios - Swift Network call with php Api endPoint -


can me following issue?

i not able retrieve value id.

the "id" alway empty when post ios network call.

swift 3 network call :

var request = urlrequest(url: url(string: "url here")!)         request.httpmethod = "post"         let poststring = "id=2"         request.httpbody = poststring.data(using: .utf8)          let task = urlsession.shared.datatask(with: request) { data, response, error in             guard let data = data, error == nil else {                                                 // check fundamental networking error                 print("error=\(error)")                 return             }              if let httpstatus = response as? httpurlresponse, httpstatus.statuscode != 200 {           // check http errors                 print("statuscode should 200, \(httpstatus.statuscode)")                 print("response = \(response)")             }              let responsestring = string(data: data, encoding: .utf8)             print("responsestring = \(responsestring)")         }         task.resume() 

api.php php code retrieve value server side.

if($_server["request_method"] == "post"){      if(isset($_post["id"]) == 0) {          $id = isset($_post["id"]);      } } 

the problem in php code. on line 3, if isset false, set $id value id-parameter. want if isset true.

change 0 1. it's small typo.

it looks might have gotten isset bit wrong. isset returns bool, whether variable has value or not. $id = isset($_post["id"]); tells if id given, not value. if want value drop isset.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -