Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »


PHP Curl

        // Url to the admin API
        $url = "https://<MASTER IP>:5656/api/admin";
        $postfields["id"] = "EXAMPLEIDKEY";
        $postfields["key"] = "EXAMPLEIDPASSWORD";
        $postfields["action"] = "reboot";
        $postfields["vserverid"] = "100";
        // Send the query to the solusvm master
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url . "/command.php");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 20);
        curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:"));
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
        $data = curl_exec($ch);

        // Parse the returned data and build an array
        preg_match_all('/<(.*?)>([^<]+)<\/\\1>/i', $data, $match);
        $result = array();
        foreach ($match[1] as $x => $y)
        $result[$y] = $match[2][$x];
  • No labels