SATS/lib/api/send

57 lines
1.1 KiB
Plaintext
Raw Normal View History

2017-01-26 19:03:08 +00:00
#!/usr/bin/php
<?php
require_once __DIR__.'/../include/const';
2017-01-26 19:03:08 +00:00
// will send the request using `auth` for cyclic hash
2017-01-27 14:54:30 +00:00
function api_send(){
2017-01-27 14:54:30 +00:00
/* [1] Fetch useful data
=========================================================*/
/* (1) Fetch target url */
$url = @file_get_contents(URL_CONF);
2017-01-27 14:54:30 +00:00
if( $url === false )
return 127;
2017-01-27 14:54:30 +00:00
/* (2) Fetch cyclic hash */
$hash = syscall(SOURCE_DIR.'/lib/cyclic-hash/hash');
2017-01-27 14:54:30 +00:00
var_dump($hash);
if( strlen($hash) != 128 )
return 127;
2017-01-27 14:54:30 +00:00
/* (3) Try new hash if available */
$new = syscall(SOURCE_DIR.'/lib/cyclic-hash/new');
var_dump('new'); var_dump($new);
2017-01-27 14:54:30 +00:00
/* (4) Decrement the hash */
var_dump( 'decr: ',syscall(SOURCE_DIR.'/lib/cyclic-hash/decr') );
2017-01-27 14:54:30 +00:00
2017-01-27 14:54:30 +00:00
/* [1] Create httpRequest basis
=========================================================*/
/* (1) Set URL */
$curl = curl_init($url);
2017-01-27 14:54:30 +00:00
/* (2) Set HTTP method -> POST */
curl_setopt($curl, CURLOPT_POST, true);
/* (3) Set headers */
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: multipart/form-data; boundary='
]);
}
echo api_send();
2017-01-26 19:03:08 +00:00
?>