Пример #1
0
 protected function getHeaders()
 {
     $config = Project::getConfig();
     $headers = array('Content-Type' => 'application/json');
     $public_key = $_SERVER['HOME'] . '/.ssh/id_rsa.pub';
     if (file_exists($public_key)) {
         $headers['X-Public-Key'] = urlencode(file_get_contents($public_key));
     }
     if (!empty($config) && isset($config['app_id']) && isset($config['key'])) {
         $headers['X-App-Id'] = $config['app_id'];
         $headers['X-App-Key'] = $config['key'];
     }
     $headers['User-Agent'] = 'hook-cli';
     return $headers;
 }
Пример #2
0
<?php

use Client\Client;
use Client\Project;
return array('arg0' => 'keys', 'command' => 'keys', 'description' => 'List all application keys.', 'run' => function ($args) {
    $client = new Client();
    $keys = $client->get("apps/keys");
    $project = Project::getConfig();
    if (!$args['json']) {
        echo "Application name: {$project['name']}" . PHP_EOL;
        echo "Application keys:" . PHP_EOL;
        foreach ($keys as $key) {
            echo "{" . PHP_EOL;
            echo "\tapp_id: {$key->app_id}" . PHP_EOL;
            echo "\tkey: " . $key->key . PHP_EOL;
            echo "\ttype: " . $key->type . PHP_EOL;
            echo "}" . PHP_EOL;
        }
        if (count($keys) > 0) {
        }
    }
    return $keys;
});