-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.php
62 lines (52 loc) · 2.06 KB
/
cli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
error_reporting(0);
require('libs/clilib.php');
require_once('libs/https.php');
require_once('libs/functionWarp.php');
function displayMenu() {
echo "===================================\n";
echo " SEOLizer CLI V1.0 \n";
echo "===================================\n";
echo "enter command and parameter\n";
echo "enter 'help' to display this help\n";
echo "exit to Exit\n";
echo "===================================\n";
}
function main() {
displayMenu();
while (true) {
echo "command: ";
$cmd = trim(fgets(STDIN));
if (strtolower($cmd) == 'help') {
displayMenu();
$cmd = '';
}
if (strtolower($cmd) == 'exit') exit(0);
$cmds = explode(" ",$cmd);
$cmdArray = parseParameters($cmd);
$command = $cmds[0];
if ($command != '') {
$para = '';
foreach ($cmdArray as $key => $value) {
$para .= $key . '=' . $value . '&';
}
require('libs/api.php');
$output = "-----------------------------------------------------------\n";
$output .= "Function: " . $result['result']['request']['action'] . "\n";
$output .= "Credit used: " . $result['result']['request']['credits'] . "\n";
if (isset($result['result']['response']['pointers']['attributes']['prikey'])) {
$output .= "Primary key: " . $result['result']['response']['pointers']['attributes']['prikey'] . "\n";
}
$output .= "-----------------------------------------------------------\n";
echo($output);
if (isset($result['result']['response']['pointers']['attributes']['prikey'])) {
if ($result['result']['response']['pointers']['attributes']['data.pointer'] != '') {
printJsonAsTable(json_encode($result['result']['response'][$result['result']['response']['pointers']['attributes']['data.pointer']]));
}
}
unset($result);
}
}
}
// Program entry point
main();