如何通过PHP调用CITRIX API以注册新的GotoWebinar参与者? [英] How do I call the CITRIX API via PHP to register a new GotoWebinar attendee?

查看:341
本文介绍了如何通过PHP调用CITRIX API以注册新的GotoWebinar参与者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码注册用户到网络研讨会:

  $ headers = array(
' HTTP / 1.1',
'Accept:application / json',
'Accept:application / vnd.citrix.g2wapi-v1.1 + json',
'Content- json',
'授权:OAuth oauth_token ='。$ access_token,
'Name_First:test',
'Name_Last:ank',
'电子邮件:ankinfo@yahoo.com ',
);

$ gtw_url =https://api.citrixonline.com/G2W/rest/organizers/{organizerkey}/webinars/{webinarkey}/registrants;
$ curl = @curl_init();
@curl_setopt($ curl,CURLOPT_HTTPHEADER,$ headers);
@curl_setopt($ curl,CURLOPT_URL,$ gtw_url);
@curl_setopt($ curl,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_0);
@curl_setopt($ curl,CURLOPT_SSL_VERIFYPEER,false);
@curl_exec($ curl);
@curl_Close($ curl);

我已经通过网络研讨会密钥和组织者密钥。我应该得到输出像:

 HTTP/ 1.1 201 OK Content-Type:application / json 
{
registrantKey:5678,
joinUrl:https://www1.gotomeeting.com/join/123456789/5678
}
  [
{
registrantKey:106660361,
firstName:test,
lastName:1,
email:rohankapoor99@yahoo.com,
status:WAITING,
registrationDate:2012-06-29T21:07:10Z,
joinUrl :https://www1.gotomeeting.com/join/141654337/106660361,
timeZone:美国/丹佛
}
]

我正在使用创建网络研讨会网址,为什么我得到已经注册的用户的信息?

解决方案

 <?php 
if(isset($ _ POST ['registration-submission'] )){
$ base_url ='https://api.citrixonline.com/G2W/rest';
$ org_key = $ _POST ['organiser_key'];
$ web_key = $ _POST ['webinar_key'];
$ access_token ='xxxxx';

$ gtwPost =(object)array(
'firstName'=> $ POST ['fname'],
'lastName'=> $ POST ['lname' ],
'email'=> $ POST ['email'],
);
$ newRegistrantFields = json_encode($ gtwPost);
$ headers = array(
'HTTP / 1.1',
'Accept:application / vnd.citrix.g2wapi-v1.1 + json',
'Content-Type: application / json',
'授权:OAuth oauth_token = xxxxx',
'Content-Length:'。strlen($ newRegistrantFields)
);


//为GoToWebinar设置POST URL
$ gtw_url = $ base_url。/ organizers /'.$ org_key。'/ webinars /'.$ web_key。'/ registrants ?resendConfirmation = false';

//开始GoToWebinar提交

$ 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);
$ newRegistrantsArray = json_decode($ newRegistrants,true);


if(array_key_exists('registrantKey',$ newRegistrantsArray)&&& array_key_exists('joinUrl',$ newRegistrantsArray)){
$ form_data ['status'] =真正;
$ form_data ['code'] = $ _POST ['Email']。 '成功注册在网络研讨会';
$ form_data ['error'] ='E300';

// echo json_encode($ form_data);
// exit;
}
}
?>

代码不工作。请帮我这个。


I am using the below code to register user to the webinar:

   $headers = array(
 'HTTP/1.1',
  'Accept: application/json',
  'Accept: application/vnd.citrix.g2wapi-v1.1+json',
  'Content-Type: application/json',
  'Authorization: OAuth oauth_token='.$access_token,
  'Name_First:test',
  'Name_Last:ank',
  'Email:ankinfo@yahoo.com',
   );

 $gtw_url = "https://api.citrixonline.com/G2W/rest/organizers/{organizerkey}/webinars/{webinarkey}/registrants";
 $curl = @curl_init();
 @curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 
     @curl_setopt($curl, CURLOPT_URL, $gtw_url);
      @curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
     @curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     @curl_exec($curl);
     @curl_close($curl);

I have passed webinar key and organizer key. I am supposed to get the output like:

HTTP/1.1 201 OK Content-Type: application/json
{
    "registrantKey":5678,
    "joinUrl":"https://www1.gotomeeting.com/join/123456789/5678"
}

The problem is that when i run the file i got output

[
    {
        "registrantKey":106660361,
        "firstName":"test",
        "lastName":"1",
        "email":"rohankapoor99@yahoo.com",
        "status":"WAITING",
        "registrationDate":"2012-06-29T21:07:10Z",
        "joinUrl":"https://www1.gotomeeting.com/join/141654337/106660361",
        "timeZone":"America/Denver"
    }
]

I am using the create webinar URL, so why am I getting the info of the user that is already registered?

解决方案

<?php
if (isset($_POST['registration-submission'])) {
$base_url = 'https://api.citrixonline.com/G2W/rest';
$org_key = $_POST['organizer_key'];
$web_key = $_POST['webinar_key'];
$access_token = 'xxxxx';

$gtwPost = (object) array(
'firstName' => $POST['fname'],
'lastName'  => $POST['lname'],
'email'=> $POST['email'],
);
$newRegistrantFields = json_encode($gtwPost);
$headers = array(
        'HTTP/1.1',
        'Accept: application/vnd.citrix.g2wapi-v1.1+json',
        'Content-Type: application/json',
        'Authorization: OAuth oauth_token=xxxxx',
         'Content-Length:' . strlen( $newRegistrantFields )
        );


//Set POST URL for GoToWebinar
$gtw_url = $base_url.'/organizers/'.$org_key.'/webinars/'.$web_key.'/registrants?resendConfirmation=false';

//Start GoToWebinar submission

$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);
$newRegistrantsArray = json_decode($newRegistrants,true);


 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;
 }
}
?>

the code is not working. Please help me with this.

这篇关于如何通过PHP调用CITRIX API以注册新的GotoWebinar参与者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆