I have problem with use NodeJitsu API in PHP curl... I want make php file which will be restart my application.
Here is NodeJistu API: https://www.nodejitsu.com/documentation/api/#restart-an-application But i don't realy now how i can use it in php. Can you help me?
They use a simple REST API. You'll need to send an empty HTTP POST request to the url named in the docs. A request body isn't required for the restart
action.
I don't have an account for testing there, but following their documentation it could look like this:
/* Login credentials */
$user = 'user';
$pass = 'secret';
/* Application id */
$application = 'foo';
/* Base url */
$baseUrl = 'https://www.nodejitsu.com';
// Create a context for the following HTTP request
$context = stream_context_create(
'http' => array(
'method' => 'POST',
'header' => 'Authorization: Basic '
. base64_encode("$user:$pass")
)
);
// Execute the HTTP request to restart the application
$url = "$baseUrl/apps/$user/$application/restart";
$response = file_get_contents($url, false, $context);
// Dump response
var_dump(json_decode($response));
You can use file_get_contents()
, curl isn't required.