Handing over data from Swift to PHP file to select restricted data

Hello,

My App should select data from an external database. The SELECT is implemented in a PHP file.

I now don’t want to select the whole database-table, so i want to use the WHERE condition.

How do i handover the data from my swift code to the PHP file in order to be able to restrict the SELECT by the WHERE condition?

Basically this is my code to call the URL of the PHP file:

let task = defaultSession.dataTask(with: url) { (data, response, error) in

Or is this the wrong method for this?

Will be an easy question for experienced developers, but i am here at a starting point in swift developement…

Thanks,

Jan

It sounds as if you don’t control the PHP file and are calling it as a web API. Is that right?

if so, then perhaps there are some parameters that you can pass to the API.

Are you able to share the endpoint that you are calling?

Hi,

well, my call of the PHP-file by url is like this:

func fetchCustomerTime() {

    **let** serviceUrl = "https://deinserver.de/api/get_today_schedule.php"

    

    **let** url = URL(string: serviceUrl)

    

    **if** **let** url = url {

        **let** session = URLSession.init(configuration: .default)

        **let** task = session.dataTask(with: url, completionHandler:

                                        { (data, response, error) **in**

            **if** error == **nil** {

                //success

                **self**.parseJsonCustomers(data!)

            }

            **else** {

                //Error

            }

        })

        //start task

        task.resume()

    }

}

So here i would expect, i can Transfer some Data… But how?

Thanks

Jan

That URL (https://deinserver.de/api/get_today_schedule.php) is a 404.

Can you point to the documentation for the web API you are trying to use? That domain does appear to have an API for domain resellers, but I don’t see anything that refers to schedules…