コード例 #1
0
ファイル: external.php プロジェクト: neevan1e/Done
 public function handle_request($not_used = null, $not_used_ignore = null)
 {
     //! determine selected option for class
     $selected_option = "";
     if (isset($_GET[ContactsHandler::$contacts_option])) {
         $selected_option = $_GET[ContactsHandler::$contacts_option];
     }
     if (!$selected_option) {
         $this->error = true;
     } else {
         $this->session_start();
         $state = $this->get_from_session($selected_option);
         $oauth_parms = array();
         if ($state) {
             //! session data is stored as url encoded string, SPUtils::parse_query returns dictionary
             $oauth_parms = SPUtils::parse_query($state);
         }
         //! check if we have verifier, or if we already have access token in session
         //! either of these conditions means we already have user authorization (we get verifier back when the user is redirected back to external.php, and __oauth_access_token is set internally to indicate that the authorized request token has been already exchanged for a access token)
         if (isset($_GET[$this->response_parm]) || isset($oauth_parms["__oauth_access_token"])) {
             $this->response = true;
         } else {
             //! remove any previous request token (if any) from session and get another one
             //! assume previous token has been declined by the user or revoked already (by default the OAuth contacts importer classes, with the exception of Yahoo, make a call to revoke the access token as soon as the contacts data is retrieved, tokens may otherwise stay valid for long time)
             $this->remove_from_session($selected_option);
             //! see parent implementation - basically what happens there is instantiating the contacts importer class and attempting access to ->contacts, which would return null with error of "external authentication needed" + redirect url where we need to send the user to authorize our token
             //! another thing that happens behind the scenes when accessing ->contacts is getting a "request token" if we don't have a token already (and we wouldn't have a token on first request)
             //! External authentication/OAuth/API's usually are provided with limits, so request tokens in this examples are only acquired when the popup window is open (the other alternative is to get a request token on the main page and use the popup for redirect only)
             parent::handle_request(array("external" => "true"));
             if (!$this->redirect_url) {
                 $this->error = true;
             }
         }
     }
     include_once "example/external.page.php";
 }
コード例 #2
0
ファイル: benoit.php プロジェクト: bilel99/oge
<?php

include_once 'example/contacts.main.php';
$handler = new ContactsHandler();
$handler->handle_request($_POST);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Contacts Importer by Svetlozar.NET (PHP)</title>
<LINK href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="content">
<div class="center">
	<form id="import_form" action="" class="center" method="post">
	<?php 
if (!$this->current_class->ExternalAuth) {
    ?>
		<table>
			<tr>
				<td>Email:</td>
				<td><input type="text" name="email" value="" style="width:90%" /></td>
			</tr>
			<tr>
				<td>Password:</td>
				<td><input type="password" name="pswd" value="" style="width:90%" /></td>
			</tr>
		</table>