Example #1
0
 if ($service == 'oauth.facebook') {
     // facebook resynchronizations are simple to perform
     $oauth_userinfo = $consumer->refresh_userinfo();
     if (empty($oauth_userinfo)) {
         $msg = 114;
         // Account saved but re-synch failed.
         COM_errorLog($MESSAGE[$msg]);
     } else {
         $consumer->doSynch($oauth_userinfo);
     }
 } else {
     // other OAuth services are more complex
     // setup what we need to callback and authenticate
     $callback_query_string = $consumer->getCallback_query_string();
     // COM_errorLog("callback_query_string={$callback_query_string}");
     $cancel_query_string = $consumer->getCancel_query_string();
     // COM_errorLog("cancel_query_string={$cancel_query_string}");
     $callback_url = $_CONF['site_url'] . '/usersettings.php?mode=synch&oauth_login=' . $service;
     // COM_errorLog("callback_url={$callback_url}");
     // authenticate with the remote service
     if (!isset($query[$callback_query_string]) && (empty($cancel_query_string) || !isset($query[$cancel_query_string]))) {
         $msg = 114;
         // Resynch with remote account has failed but other account information has been successfully saved
         // elseif the callback query string is set, then we have successfully authenticated
     } elseif (isset($query[$callback_query_string])) {
         // COM_errorLog("authenticated with remote service, retrieve userinfo");
         // foreach($query as $key=>$value) {
         //     COM_errorLog("query[{$key}]={$value}");
         // }
         $oauth_userinfo = $consumer->sreq_userinfo_response($query);
         if (empty($oauth_userinfo)) {