Zoom

繝ヲ繝シ繧カ繝シ諠蝣ア蜿門セ

function urlsafe_base64_encode($str){
縲return str_replace(array('+','/','='), array('-','_',''), base64_encode($str));
}

$API_Key = 'XXXXXXXXXXXXXXXXXXXXXX';
$API_Secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$expiration = time() + 5;//5遘

$header = urlsafe_base64_encode('{"alg":"HS256","typ":"JWT"}');
$payload = urlsafe_base64_encode('{"iss":"'.$API_Key.'","exp":'.$expiration.'}');
$signature = urlsafe_base64_encode(hash_hmac('sha256', "$header.$payload", $API_Secret, TRUE));
$token = "$header.$payload.$signature";

$curl = curl_init();

curl_setopt_array($curl, array(
縲縲CURLOPT_URL => "https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1",
縲縲CURLOPT_RETURNTRANSFER => true,
縲縲CURLOPT_ENCODING => "",
縲縲CURLOPT_MAXREDIRS => 10,
縲縲CURLOPT_TIMEOUT => 30,
縲縲CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
縲縲CURLOPT_CUSTOMREQUEST => "GET",
縲縲CURLOPT_HTTPHEADER => array(
縲縲縲縲"authorization: Bearer ${token}",
縲縲縲縲"content-type: application/json"
縲縲),
));

$response = curl_exec($curl);
curl_close($curl);

$json = json_decode( $response , true ) ;
print($json["users"][0]["id"]."\r\n");

繝医シ繧ッ繝ウ蜿門セ

$API_Key = 'XXXXXXXXXXXXXXXXXXXXXX';
$API_Secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$Redirect_URL = 'https://sample.office-yone.com/sample2/redirect.php';

if(!isset($_GET['code'])){
縲縲echo 'Authorization Error';
}

$basic = base64_encode($API_Key.':'.$API_Secret);

$curl = curl_init();

curl_setopt_array($curl, array(
縲縲CURLOPT_URL => "https://zoom.us/oauth/token?grant_type=authorization_code&code={$_GET['code']}&redirect_uri=$Redirect_URL",
縲縲CURLOPT_RETURNTRANSFER => true,
縲縲CURLOPT_ENCODING => "",
縲縲CURLOPT_MAXREDIRS => 10,
縲縲CURLOPT_TIMEOUT => 30,
縲縲CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
縲縲CURLOPT_CUSTOMREQUEST => "POST",
縲縲CURLOPT_HTTPHEADER => array(
縲縲縲縲"authorization: Basic $basic"
縲縲),
));

$response = curl_exec($curl);
curl_close($curl);

$json = json_decode( $response , true ) ;

繝溘シ繝繧」繝ウ繧ー諠蝣ア蜿門セ

繝ヲ繝シ繧カ繝シID縲√ヨ繝シ繧ッ繝ウ縺ッ竊代〒蜿門セ

$curl = curl_init();

curl_setopt_array($curl, array(
縲縲CURLOPT_URL => "https://api.zoom.us/v2/users/${userId}/meetings?page_number=1&page_size=30&type=live",
縲縲CURLOPT_HTTPHEADER => array(
縲縲縲縲"authorization: Bearer ${token}",
縲縲縲縲"content-type: application/json"
縲縲),
));

$response = curl_exec($curl);
curl_close($curl);

$json = json_decode( $response , true ) ;

Follow me!