G2W integration with Drupal


I recently had to work with gotowebinar integration for one of my client projects drupal based.

The task is that the user can able to signup for the webinars( payment based) through drupal site, once user completes the payment i will be registering the signed up user to the registrants lists in go to 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.

switch($op){
//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);
}}

break;

}}

// 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_RETURNTRANSFER, TRUE);

   curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
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);
curl_close($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)

Hope it saves some one headache.

Advertisements
About

Working For Cause Not For Applause

Tagged with: , , , , ,
Posted in Drupal

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: