Sunday 1 January 2012

Gotomeeting php api(oauth) create meting

This is from https://developer.citrixonline.com/forum/create-meeting-error , the code from bcantoni:
Create a METING:


 <;∧php

// sample GoToMeeting API call: create meeting
// docs: https://developer.citrixonline.com/api/GoToMeeting%2520REST%2520API/Create%2520Meeting-150

// assume have valid $access_token from OAuth flow
$access_token = 'xyz';

$url = "https://api.citrixonline.com/G2M/rest/meetings";
$headers = array (
    "Accept: application/json",
    "Content-Type: application/json",
    "Authorization: OAuth oauth_token=$access_token"
);
$data = array ('test meeting',
    'starttime' => '2012-02-01T08:00:00',
    'endtime' => '2012-02-01T09:00:00',
    'timezonekey' => '67', // Pacific time
    'meetingtype' => 'Scheduled',
    'passwordrequired' => 'false',
    'conferencecallinfo' => 'Hybrid' // normal PSTN + VOIP options
);
$data_json = json_encode ($data);
 
$ch = curl_init();
curl_setopt_array ($ch, array (
    CURLOPT_URL => $url,
    CURLOPT_HEADER => false,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $data_json,
));
 
$results = curl_exec ($ch);
$info = curl_getinfo ($ch);
curl_close ($ch);
 
print "data sent: $data_json\n";
//print "headers sent: " . print_r($headers,1) . "\n";
//print "curl info: " . print_r($info,1) . "\n";
print "data returned: " . print_r($results,1 ) . "\n";
//print "data returned decoded: " . print_r(json_decode($results),1) . "\n";

And the response:

$ php post.php
 
data sent: {"subject":"test meeting","starttime":"2012-02-01T08:00:00","endtime":"2012-02-01T09:00:00","timezonekey":"67","meetingtype":"Scheduled","passwordrequired":"false","conferencecallinfo":"Hybrid"}
 
data returned: {"joinURL":"https:\/\/www3.gotomeeting.com\/join\/123456789","maxParticipants":26,"uniqueMeetingId":2000007959645,"meetingid":123456789}
EDIT:


thaks for the response, but I still get the same error with your code :). Here is the output from the php:

data sent:
Array
(
    [0] => test meeting
    [starttime] => 2012-02-01T08:00:00
    [endtime] => 2012-02-01T09:00:00
    [timezonekey] => 67
    [meetingtype] => Scheduled
    [passwordrequired] => false
    [conferencecallinfo] => Hybrid
)

data returned:
{"int_err_code":"Server.userException","msg":"java.lang.NumberFormatException: Invalid date/time"}curl info:
Array
(
    [url] => https://api.citrixonline.com/G2M/rest/meetings
    [content_type] => text/xml; charset=utf-8
    [http_code] => 404
    [header_size] => 224
    [request_size] => 483
    [filetime] => -1
    [ssl_verify_result] => 20
    [redirect_count] => 0
    [total_time] => 2.797
    [namelookup_time] => 0
    [connect_time] => 0
    [pretransfer_time] => 0.438
    [size_upload] => 712
    [size_download] => 98
    [speed_download] => 35
    [speed_upload] => 254
    [download_content_length] => 98
    [upload_content_length] => 712
    [starttransfer_time] => 2.438
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

)


And from fidler:

POST https://api.citrixonline.com/G2M/rest/meetings HTTP/1.1
Host: api.citrixonline.com
Accept: application/json
Authorization: OAuth oauth_token=1c8187be36bb86997db59e5772268d5a
Content-Length: 712
Expect: 100-continue
Content-Type: application/json; boundary=----------------------------9530b5163dde

------------------------------9530b5163dde
Content-Disposition: form-data; name="starttime"

2012-02-01T08:00:00
------------------------------9530b5163dde
Content-Disposition: form-data; name="endtime"

2012-02-01T09:00:00
------------------------------9530b5163dde
Content-Disposition: form-data; name="timezonekey"

67
------------------------------9530b5163dde
Content-Disposition: form-data; name="meetingtype"

Scheduled
------------------------------9530b5163dde
Content-Disposition: form-data; name="passwordrequired"

false
------------------------------9530b5163dde
Content-Disposition: form-data; name="conferencecallinfo"

Hybrid
------------------------------9530b5163dde--



and the response:


HTTP/1.1 404 Not Found
Date: Sun, 01 Jan 2012 10:57:14 GMT
Server: Apache
Content-Length: 98
Content-Type: text/xml; charset=utf-8
Cneonction: close
Vary: Accept-Encoding
Connection: close

{"int_err_code":"Server.userException","msg":"java.lang.NumberFormatException: Invalid date/time"}

2 comments:

  1. I'm not getting a return when I use this code. All that was changed is the access token and the dates. is this example no longer valid?

    ReplyDelete
  2. hi, sorry to say but the code is wrong, this was a reply from a guy at citrex, for him this worked, but I talked to a lot of other devs that had the same problem, the api is still in a bad state.

    I finally used the code here: http://cuzztuts.blogspot.ro/2011/12/gotomeeting-php-apioauth-implementation.html with some modifications that I don't remember. If you are in the same situation like I was (searched for a solution to create a meeting and I found only problems that others did not help) I can search for the solution that I used in my old code

    ReplyDelete