这个问题已有 3 年历史了,但考虑到 CITRIX(现在的 LogMeIn)API 文档目前的惨淡状态,我提供以下代码片段作为可能的解决方案:
显然,我们需要我们帐户的组织者密钥和访问令牌数据......
$organizer_key= '10000000000XXXXXXX';
$access_token = 'GwsiiPWaJbHIiaIiocxxxxxxxxxx';
获取网络研讨会所需的最少字段(例如从 HTML 表单)并对数据进行 JSON 编码...
$newRegFields = (object) array(
'firstName' => $_POST[ 'FirstName' ],
'lastName' => $_POST[ 'LastName' ],
'email' => $_POST[ 'Email' ],
);
$newRegistrantFields = json_encode( $newRegFields );
//echo '<br><br>' . $newRegistrantFields;
参加网络研讨会...
$webinarID = preg_replace( "/[^0-9]/", "", $_POST[ "WebinarKey" ] );
将 URL 设置为 LogMeIn API(重发确认选项不是必需的)...
$gtw_url = "https://api.citrixonline.com/G2W/rest/organizers/" . $organizer_key . "/webinars/" . $webinarID . "/registrants?resendConfirmation=false";
格式化我们的 POST 标头...
$headers = array(
"HTTP/1.1",
"Accept: application/json",
"Content-Type: application/json",
"Authorization: OAuth oauth_token=$access_token",
"Content-Length: " . strlen( $newRegistrantFields )
);
设置我们的 cURL 选项,确保我们指定一个 POST卷曲_POST, 1 ...
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $gtw_url );
curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_POST, 1 );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $newRegistrantFields );
$newRegistrants = curl_exec( $curl );
curl_close( $curl );
我们的 cURL 调用已返回 JSON 编码数据,无论是服务器错误消息还是注册确认。现在让我们将回复转换成一个方便的关联数组......
$newRegistrantsArray = json_decode( $newRegistrants, true );
//echo '<br><br>' . $newRegistrants . '<br><br>';
//echo '<pre>'; print_r( $newRegistrantsArray ); echo '</pre>';
If the 错误代码钥匙被退回,然后注册被轰炸了。我在这里所做的就是从服务器获取实际的错误描述并将其加载以返回到我的调用 HTML 页面,但这完全是可选的...
if( array_key_exists( 'errorCode', $newRegistrantsArray )) {
$form_data[ 'status' ] = false;
$form_data[ 'code' ] = $newRegistrantsArray[ 'description' ];
$form_data[ 'error' ] = 'E200';
//echo json_encode( $form_data );
//exit;
}
现在,如果注册成功,服务器将返回类似...
(
[registrantKey] => 2.5022062212198E+18
[joinUrl] => https://global.gotowebinar.com/join/6552167171182613761/103193261
)
...所以我只是检查这些钥匙是否已归还,如果是,我知道注册良好。
if( array_key_exists( 'registrantKey', $newRegistrantsArray ) && array_key_exists( 'joinUrl', $newRegistrantsArray ) ) {
$form_data[ 'status' ] = true;
$form_data[ 'code' ] = $_POST[ 'Email' ] . ' successfully registered with webinar';
$form_data[ 'error' ] = 'E300';
//echo json_encode( $form_data );
//exit;
}