我在PHP中使用NodeJitsu API有问题.我需要make文件,它将重新启动我的应用程序。
下面是NodeJistu API:https://www.nodejitsu.com/documentation/api/#restart-an-application,但我现在不知道如何在php中使用它。你能帮帮我吗?
发布于 2014-09-10 22:21:30
他们使用一个简单的REST。您需要向文档中指定的url发送一个空的HTTP请求。restart操作不需要请求体。
我没有用于那里测试的帐户,但是根据他们的文档,它可能如下所示:
/* 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));你可以使用file_get_contents(),卷发不是必需的。
https://stackoverflow.com/questions/25726494
复制相似问题