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 ) ;