POST */ curl_setopt($curl, CURLOPT_POST, true); /* [3] Manage post data =========================================================*/ /* (1) Set post data */ $postarray = [ 'token' => $hash, 'data' => json_encode($data) ]; /* (2) Add renew if renew */ if( strlen($new) == 128 ) $postarray['renew'] = $new; /* (3) Set postdata raw to curl */ curl_setopt($curl, CURLOPT_POSTFIELDS, $postarray); /* [4] Send and catch request response =========================================================*/ /* (1) Send and catch response */ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); /* (2) Close request */ //curl_close($curl); /* (3) Return response as result */ if( $response === false ){ slog("Request error", 'api:sync','update'); return 127; } /* [5] Decrement cyclic-hash so request has ran successfully =========================================================*/ /* (1) Decrement the hash */ $decr = syscall(SOURCE_DIR.'/lib/cyclic-hash/decr'); if( $decr === false ){ slog("cyclic-hash:decr returned $decr EXIT_STATUS", 'api:sync','update'); return 127; } /* [5] Response management =========================================================*/ /* (1) Writes request to temporary pipe */ file_put_contents(TMP_DIR.'/api.response', $response); /* (2) Manage response deployement */ $deploy = syscall(SOURCE_DIR.'/lib/api/deploy'); /* (3) Return state */ return ($deploy === true); } echo api_request(); ?>