Remote Spark Web App

Reviving an old thread. I’m tweaking this web app to send a function request to my Electron, using the php method to hide my access token. Trouble is I don’t understand web code thus I don’t know if I’ve formed this correctly. When I look at the response it seems weird to me, in regards to all the params. The Electron is currently onsite and powered off so I won’t get a response from it regardless until it’s turned on but is someone able to at least give me an idea if I’m on the right track please.
I would also like to provide some feedback if the Electron is offline. I just can’t get my head around how I set this up.

I’ve changed my html from this

    function doMethod(method, data) {
      var url = baseURL + coreID + "/" + method;
      $.ajax({
        type: "POST",
        url: url,
        data: {
          access_token: accessToken,
          args: data
        },

to this

    function doMethod(method, data) {
      var url = baseURL + "?device=" + deviceID +"&method=" + method;
      $.ajax({
        type: "POST",
        url: url,
        data: {
         args: data
        },

and added my access token in the php which looks like this

<?php
$device = $_REQUEST["device"];
$method = $_REQUEST["method"];
if(!$device||!$method) die("device or method param missing\n");
// add access token
$_REQUEST["access_token"] = "12345678987654321";
// create params
$params = http_build_query($_REQUEST);
// make request
$url = "https://api.particle.io/v1/devices/" . $device . "/" . $method . "?" . $params;

$response = file_get_contents($url);
echo $response; 
?>

Using the console in Microsoft Edge I see that the response is:

<b>Warning</b>:  file_get_contents(https://api.particle.io/v1/devices/4c002b000951343334363138/raise?device=4c002b000951343334363138&amp;method=raise&amp;args=raiseit&amp;access_token=12345678987654321): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found