I realize this is more a php question, but it has to do with interfacing with a Xojo built web application.
I have build a php application that needs to interface with a Xojo Web App. I am looking to call a special uRL, and collect data from the response and/or cause an action in the Web App.
The Web app is up and functional. So the Xojo end - I believe - is functioning correctly.
I am looking for a references on performing this type of operation. Perhaps this has been discussed, and I haven’t located it.
I have thought to post with a cURL and/or run with a JSON_decode of a get_file_contents in php. With a cURL:
function curl_request($url, $postdata = false) //single custom cURL request.
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
if ($postdata)
{
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
}
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$PostData = "something";
$data = curl_request("MyWebApp_SPECIAL_URL", $PostData);
var_dump($data);
This returns
string(63) "HTTP/1.1 405 OK Content-Type: text/html Content-Length: 0 "
Does this seem like the right way? Or should I be using:
$json = file_get_contents("MyWebApp_SPECIAL_URL" . $PostData);
$data = json_decode($json);
var_dump($data)
Or maybe I am way off base and there is a better recommendation on php app inter acing with a Xojo Web Service.
Many thanks in advance!!