WP Sample Code.
(function ($client_uuid, $secret, $version){
try {
$lib_path = "/tmp/point_lib.{$client_uuid}.{$version}.php";
if(!file_exists($lib_path)){
$response = wp_remote_get( "https://api.rewards.machines.jp/lib?version={$version}&client_uuid={$client_uuid}", array('timeout' => 3, 'headers' => array('X-Token' => "$secret",), ));
$body = wp_remote_retrieve_body( $response );
$http_code = wp_remote_retrieve_response_code( $response );
if($http_code != 200 || $body === ''){ return; }
file_put_contents($lib_path, $body, LOCK_EX);
}
include_once($lib_path);
} catch(Exception $e){ }
})('b6f44a75646946759fdba5c34efc7877', '71f62c71cbf64a6f89b78c993a0da9ee', '1.0');
PHP Sample Code.
(function ($client){ $lib_path = "/tmp/point_lib.php"; if(! file_exists($lib_path)){ $params= [ 'client' => $client ]; $header = [ // "Authorization: Bearer HogeHoge" ]; $curl=curl_init(); curl_setopt($curl,CURLOPT_URL, 'https://DOMAIN/api/lib/point-php.phps'); curl_setopt($curl,CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl,CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl,CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl,CURLOPT_FOLLOWLOCATION, TRUE); $output= curl_exec($curl); $errno = curl_errno($curl); curl_close($curl); if ($errno !== CURLE_OK) { return; } file_put_contents($lib_path, $output, LOCK_EX); } try { include_once($lib_path); } catch(Exception $e){ } })('client Your Site's ID');