Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NodeJitsu PHP Curl Json API-重新启动应用程序_Php_Json_Curl_Nodejitsu - Fatal编程技术网

NodeJitsu PHP Curl Json API-重新启动应用程序

NodeJitsu PHP Curl Json API-重新启动应用程序,php,json,curl,nodejitsu,Php,Json,Curl,Nodejitsu,我在PHP curl中使用NodeJitsu API时遇到问题。。。 我想使php文件将重新启动我的应用程序 以下是NodeJistu API: 但我现在不知道如何在php中使用它。你能帮我吗?他们使用一个简单的RESTAPI。您需要向文档中指定的url发送一个空HTTP POST请求。重新启动操作不需要请求正文 我没有在那里进行测试的帐户,但根据他们的文档,它可能看起来像这样: /* Login credentials */ $user = 'user'; $pass = 'secret';

我在PHP curl中使用NodeJitsu API时遇到问题。。。 我想使php文件将重新启动我的应用程序

以下是NodeJistu API:
但我现在不知道如何在php中使用它。你能帮我吗?

他们使用一个简单的RESTAPI。您需要向文档中指定的url发送一个空HTTP POST请求。
重新启动操作不需要请求正文

我没有在那里进行测试的帐户,但根据他们的文档,它可能看起来像这样:

/* 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));

您可以使用
文件获取内容()
,不需要卷曲。

哇!谢谢你的代码,我做了一些改变,现在它的工作!你能告诉我,我如何使用相同的API获取日志吗因为我知道我需要发送一个带有后期操作的数组。这就是你所说的身体?我仍然可以使用file_get_contets()而不是curl?@Xawier是的,您需要发送一个post body(json)-如文档中所述。检查此页面,该页面显示如何发送带有
文件\u get\u contents()的帖子正文。