1

我正在尝试使用 REST API 获取应用程序进程状态,但在让它返回良好数据时遇到了一些麻烦

    $ch = curl_init( );

    curl_setopt( $ch, CURLOPT_URL, 'https://api.heroku.com');  // No clue what to put here. 
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt( $ch, CURLOPT_USERPWD, ":yesthisismyrealapikeyanditworks");   // trust me on this line :)
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json')); //total guess
    curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt( $ch, CURLOPT_POSTFIELDS, 'https://api.heroku.com/apps/myapp/ps');  // where myapp is actually my app name

    // Getting results
    return  curl_exec($ch); 

这没有返回任何有用的东西。我是 JSON 和 curl 的新手,所以请放轻松。谢谢。

戴夫

4

1 回答 1

1
$ch = curl_init( );
curl_setopt( $ch, CURLOPT_URL, 'https://api.heroku.com/apps/myapp/ps');
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_USERPWD, ":yesthisismyrealapikeyanditworks");
return  curl_exec($ch); 
于 2012-09-21T14:49:59.637 回答