-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from teodortalov/1.1-dev
1.1 dev
- Loading branch information
Showing
9 changed files
with
289 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,20 +5,17 @@ | |
|
||
require_once 'vendor/autoload.php'; | ||
|
||
use Citrix\Citrix; | ||
use Citrix\GoToWebinar; | ||
use Citrix\Entity\Consumer; | ||
|
||
//authenticate | ||
$client = new Citrix('CONSUMER_KEY'); | ||
//authenticate with direct authentication | ||
$client = new \Citrix\Authentication\Direct('CONSUMER_KEY'); | ||
$client->auth('USERNAME', 'PASSWORD'); | ||
|
||
//get upcoming weibnars | ||
$goToWebinar = new GoToWebinar($client); | ||
$goToWebinar = new \Citrix\GoToWebinar($client); | ||
$webinars = $goToWebinar->getUpcoming(); | ||
|
||
//get info for a single webinar | ||
/* @var $webinar Citrix\Enttiy\Webinar */ | ||
/* @var $webinar \Citrix\Entity\Webinar */ | ||
$webinar = reset($webinars); | ||
|
||
//get registraion/join url | ||
|
@@ -32,7 +29,7 @@ | |
|
||
//register a user for a webinar | ||
$data = array('email' => '[email protected]', 'firstName' => 'Teodor', 'lastName' => 'Talov'); | ||
$consumer = new Consumer($client); | ||
$consumer = new \Citrix\Entity\Consumer($client); | ||
$consumer->setData($data)->populate(); | ||
|
||
$registration = $webinar->registerConsumer($consumer); | ||
|
@@ -42,3 +39,9 @@ | |
} | ||
|
||
var_dump('You just registered!'); | ||
|
||
//get past weibnars | ||
$goToWebinar = new \Citrix\GoToWebinar($client); | ||
$webinars = $goToWebinar->getPast(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: teodor | ||
* Date: 5/8/15 | ||
* Time: 1:23 AM | ||
*/ | ||
|
||
namespace Citrix\Authentication; | ||
|
||
/* | ||
* Wrapper class for all authentication methods. | ||
* It could be used for a single point of entry foo authentication functionality. | ||
*/ | ||
class Client { | ||
|
||
private $authentication; | ||
public function __construct($authentication = 'Direct'){ | ||
|
||
$this->setAuthentication($authentication); | ||
} | ||
|
||
public function auth(){ | ||
return $this->getAuthentication()->auth(); | ||
} | ||
/** | ||
* @return mixed | ||
*/ | ||
public function getAuthentication() | ||
{ | ||
return $this->authentication; | ||
} | ||
|
||
/** | ||
* @param string $authentication | ||
*/ | ||
public function setAuthentication($authentication) | ||
{ | ||
$class = '\\Citrix\\Authentication\\' . $authentication; | ||
$this->authentication = new $class(); | ||
return $this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: teodor | ||
* Date: 5/8/15 | ||
* Time: 1:23 AM | ||
*/ | ||
|
||
namespace Citrix\Authentication; | ||
|
||
use Citrix\ServiceAbstract; | ||
use Citrix\CitrixApiAware; | ||
|
||
/** | ||
* Citrix Authentication | ||
* | ||
* Use this class to authenticate into Citrix APIs. | ||
* | ||
* @uses \Citrix\ServiceAbstract | ||
* @uses \Citrix\CitrixApiAware | ||
*/ | ||
|
||
class Direct extends ServiceAbstract implements CitrixApiAware | ||
{ | ||
|
||
/** | ||
* Authentication URL | ||
* @var String | ||
*/ | ||
private $authorizeUrl = 'https://api.citrixonline.com/oauth/access_token'; | ||
|
||
/** | ||
* API key or Secret Key in Citrix's Developer Portal | ||
* @var String | ||
*/ | ||
private $apiKey; | ||
|
||
/** | ||
* Access Token | ||
* @var String | ||
*/ | ||
private $accessToken; | ||
|
||
/** | ||
* Organizer Key | ||
* @var int | ||
*/ | ||
private $organizerKey; | ||
|
||
/** | ||
* Being here bu passing the api key | ||
* | ||
* @param String $apiKey | ||
*/ | ||
public function __construct($apiKey = null) | ||
{ | ||
$this->setApiKey($apiKey); | ||
} | ||
|
||
/** | ||
* Authenticate by passing username and password. Those are | ||
* the same username and password that you use to login to | ||
* www.gotowebinar.com | ||
* | ||
* @param String $username | ||
* @param String $password | ||
* @return \Citrix\Citrix | ||
*/ | ||
public function auth($username, $password) | ||
{ | ||
|
||
if(is_null($this->getApiKey())){ | ||
$this->addError('Direct Authentication requires API key. Please provide API key.'); | ||
return $this; | ||
} | ||
|
||
if(is_null($username) || is_null($password)){ | ||
$this->addError('Direct Authentication requires username and password. Please provide username and password.'); | ||
return $this; | ||
} | ||
|
||
$params = array( | ||
'grant_type' => 'password', | ||
'user_id' => $username, | ||
'password' => $password, | ||
'client_id' => $this->getApiKey() | ||
); | ||
|
||
$this->setHttpMethod('GET') | ||
->setUrl($this->authorizeUrl) | ||
->setParams($params) | ||
->sendRequest() | ||
->processResponse(); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* | ||
* @return the $apiKey | ||
*/ | ||
public function getApiKey() | ||
{ | ||
return $this->apiKey; | ||
} | ||
|
||
/** | ||
* | ||
* @param String $apiKey | ||
*/ | ||
public function setApiKey($apiKey) | ||
{ | ||
$this->apiKey = $apiKey; | ||
|
||
return $this; | ||
} | ||
|
||
/* (non-PHPdoc) | ||
* @see \Citrix\CitrixApiAware::processResponse() | ||
*/ | ||
public function processResponse() | ||
{ | ||
$response = $this->getResponse(); | ||
|
||
if (empty($response)) { | ||
return $this; | ||
} | ||
|
||
if (isset($response['int_err_code'])) { | ||
$this->addError($response['msg']); | ||
return $this; | ||
} | ||
|
||
$this->setAccessToken($response['access_token']); | ||
$this->setOrganizerKey($response['organizer_key']); | ||
return $this; | ||
} | ||
|
||
/** | ||
* | ||
* @return the $accessToken | ||
*/ | ||
public function getAccessToken() | ||
{ | ||
return $this->accessToken; | ||
} | ||
|
||
/** | ||
* | ||
* @param String $accessToken | ||
*/ | ||
public function setAccessToken($accessToken) | ||
{ | ||
$this->accessToken = $accessToken; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* | ||
* @return the $authorizeUrl | ||
*/ | ||
public function getAuthorizeUrl() | ||
{ | ||
return $this->authorizeUrl; | ||
} | ||
|
||
/** | ||
* | ||
* @param string $authorizeUrl | ||
*/ | ||
public function setAuthorizeUrl($authorizeUrl) | ||
{ | ||
$this->authorizeUrl = $authorizeUrl; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* | ||
* @return the $organizerKey | ||
*/ | ||
public function getOrganizerKey() | ||
{ | ||
return $this->organizerKey; | ||
} | ||
|
||
/** | ||
* | ||
* @param int $organizerKey | ||
*/ | ||
public function setOrganizerKey($organizerKey) | ||
{ | ||
$this->organizerKey = $organizerKey; | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.