<?php

require_once 'ConstantContact.php';
require_once 'config.php';
session_start();
// Istantiate a new oAuth2 object by passing in all the necesssary
// information to authenticate
$oAuth2 = new CTCTOauth2($apikey, $consumersecret, $verificationURL, $_GET["code"]);
// trade your code in for an access token by doing a POST
$token = $oAuth2->getAccessToken();
// store information into the array to pass into the DataStore object
$sessionConsumer = array('username' => $_GET["username"], 'access_token' => $token);
$Datastore = new CTCTDataStore();
$Datastore->addUser($sessionConsumer);
if (isset($_SESSION["backto"])) {
    // if you set a return url and have stored it into backto
    $returnURL = $_SESSION["backto"];
}
// refresh the page to where you want to send them
header('Location:' . $returnURL);
?>






<a href="https://ryandavis.co/CTCT-OAuth2/index.php">You have

	authenticated, Go back</a>
Beispiel #2
0
 function admin_setup()
 {
     //   $this->admin_add_style_js('setup');
     $ccontact_set = false;
     $ccontact_valid = false;
     if (isset($_GET['code']) && isset($_GET['username'])) {
         $ccontact_set = true;
         update_option('hc_constant_contact_username', $_GET['username']);
         update_option('hc_constant_contact_code', $_GET['code']);
         if (!class_exists("ConstantContact")) {
             require_once 'includes/apis/CTCT-OAuth2/ConstantContact.php';
         }
         $apikey = get_option('hc_constantcontact_appkey');
         $csecret = get_option('hc_constantcontact_appid');
         $vUrl = admin_url() . "admin.php?page=hybridConnectAdminSetup";
         $ccontact_valid = false;
         try {
             $oAuth2 = new CTCTOauth2($apikey, $csecret, $vUrl, $_GET["code"]);
             // trade your code in for an access token by doing a POST
             $token = $oAuth2->getAccessToken();
             update_option('hc_constant_contact_token', $token);
             $ConstantContact = new ConstantContact("oauth2", $apikey, $_GET['username'], $token);
             if ($token && $token != '') {
                 $ccontact_valid = true;
             }
         } catch (Exception $e) {
             $ccontact_valid = false;
         }
     } else {
         if (isset($_GET["code"]) && !isset($_GET["username"])) {
             // gotowebinar
             require_once 'includes/apis/g2w/citrix.php';
             $citrix = new Citrix(get_option('hc_g2w_app_id'));
             $hcg2wError = false;
             try {
                 $g2worganizerKey = $citrix->get_organizer_key();
                 update_option("hc_g2w_organizer_key", $g2worganizerKey);
                 update_option("hc_g2w_error", "");
             } catch (Exception $e) {
                 update_option("hc_g2w_error", $citrix->pr($e->getMessage()));
                 $hcg2wError = true;
                 update_option("hc_g2w_valid", "false");
             }
             try {
                 $g2waccesssToken = $citrix->get_access_token();
                 update_option("hc_g2w_access_token", $g2waccesssToken);
                 update_option("hc_g2w_error_2", "");
             } catch (Exception $e) {
                 update_option("hc_g2w_error_2", $citrix->pr($e->getMessage()));
                 $hcg2wError = true;
                 update_option("hc_g2w_valid", "false");
             }
             if (get_option("hc_g2w_organizer_key") != "" && get_option("hc_g2w_access_token") != "") {
                 update_option("hc_g2w_valid", "true");
             }
         }
     }
     $my_services = $this->_get_services_array();
     include 'includes/hc_admin_setup.php';
 }