June 01, 2014

June 01, 2014
In this article, we are going to discuss about How to integrate the G2W (Goto Webinar) module with Drupal. G2W is useful for the User to signup for the webinars (payment based) through our site. Once the user completed the payment, it will registering the user to the registrants list in G2W (Goto Webinar) ( where actually they are hosting the webinars).

The Most important thing that you know when you registering in gotowebinar is about the webinar key (Which is available after you schedule a webinar). Check details on how to schedule and host a webinar here. http://www.gotomeeting.com/fec/webinar. I decided to write a curl function to the registration URL and submit the values collected from my order information.

I used hook_order API to check whether the order is Completed and based on the Status i'm submitting the User Details to the gotowebinar registrant URL.

Below is my completed process/code to submit user information in G2W.

1. Created a new field in your product class "goto_webinars_key"( you will find out this,once you scheduled a webinar in go to webinar)

2. Create a custom module with the following functions

function YOURMODULE_order($opt, &$arg1, $arg2){
$order = &$arg1;
$user = user_load($order->uid); // user info from the Order.
//We only care about completed updates and that needs to be execute once in the System
case 'update':
if ($arg1->order_status == 'payment_received' && arg2 == 'completed'){

//loop through each product item in the cart
foreach ($order->products as $product){
$n = node_load($product->nid);
if ($n->field_goto_webinars_key[0][value]){
YOURMODULE_gotowebinar($n->field_goto_webinars_key[0][value], $user);

// curl operation to submit the users into go to webinar registration.
function YOURMODULE_gotowebinar($WebinarKey, $account){
$gtwPost = "";

//Create string for GoToWebinar from same form POST data
$Form = "webinarRegistrationForm";
$gtwPost = "WebinarKey=" . urlencode($WebinarKey)
. "&Form=" . urlencode($Form)
. "&Name_First=" . urlencode($account->profile_firstname)
. "&Name_Last=" . urlencode($account->profile_lastname)
. "&Email=" . urlencode($account->mail)
. "&Company=" . urlencode($account->profile_company)
. "&Title=" . urlencode($account->profile_title);

//Set POST URL for GoToWebinar
$gtw_url = "https://attendee.gotowebinar.com/register/$WebinarKey”;// This URl will be got from the registration url after you scheduled a webinar

//Start GoToWebinar submission
$curl = curl_init();
curl_setopt($curl, CURLOPT_POSTFIELDS, $gtwPost);
curl_setopt($curl, CURLOPT_URL, $gtw_url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // it skips the curl version check if your curl is different.
$er = curl_exec($curl);
$info = curl_getinfo($curl);

3. Enable the module and now it will submit users in the Go to Webinar.

The above code is sample to do with the normal Ubercart Product. I used signup module also to track webinars in my drupal system( Let me know if you want me to post the workflow of that too)


Post a Comment