Skip to content

Instantly share code, notes, and snippets.

@kenichimiki
Created September 20, 2019 07:48
Show Gist options
  • Save kenichimiki/44f3d7c24778cceaec8e61b3a86078ba to your computer and use it in GitHub Desktop.
Save kenichimiki/44f3d7c24778cceaec8e61b3a86078ba to your computer and use it in GitHub Desktop.
Sample of how to call the Mezamashi Park jankenApi from PHP script.
function updatePredict($date, $times, $predict,$api_key){
$post_data = [
"mod" => "updatePredict",
"date" => $date,
"times" => $times,
"predict" => $predict
];
//curl実行
$curl = curl_init("https://janken.miki-ie.com/jankenApi.php");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($post_data));
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charser=UTF-8',
'Authorization: Bearer ' . $api_key
));
// ステータスコード取得
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$response = curl_exec($curl);
$request = json_decode($response, true);
curl_close($curl);
}
$api_key = "@@API_KEY@@";
updatePredict('2019-10-01',1,1,$api_key);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment