The following is a very simple PHP client, it requires the Zend Google Data Client Library. Certainly not complete but builds the initial connection with a single use token. Based on Google Base PHP example, here.
<?php
/* Load the Zend Gdata classes. */
set_include_path(dirname(__FILE__) . '/ZendGdata-1.0.1/library');
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
/**
* We arrive here when the user first comes to the form. The first step is
* to have them get a single-use token.
*/
function showIntroPage() {
global $itemsFeedURL;
$next_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$redirect_url = "https://www.dopplr.com/api/AuthSubRequest?scope=http://www.dopplr.com&next=".$next_url."&session=1";
print '<html>' . "n";
print '<head><title>PHP Demo: Dopplr API</title>' . "n";
print '<link rel="stylesheet" type="text/css" href="http://code.google.com/css/dev_docs.css">' . "n";
print '</head>' . "n";
print '<body><center>' . "n";
print '<table style="width:50%;">' . "n";
print '<tr>' . "n";
print '<th colspan="2" style="text-align:center;">PHP Demo: Dopplr API' .
'<br><font size=-1><span style="font-variant: small-caps;">Powered By</span>' .
' <a href="http://framework.zend.com/download/gdata">' .
'Zend Google Data Client Library</a></font></th>' . "n";
print '</tr>' . "n";
print '<tr><td>Before you get started, please <a href="' . $redirect_url .
'">sign in</a> to your Dopplr account.</td></tr>' . "n";
print '</table>' . "n";
print '</center></body></html>' . "n";
}
/**
* We arrive here after the user first authenticates and we get back
* a single-use token.
*/
function showFirstAuthScreen() {
global $gdata;
$singleUseToken = $_GET['token'];
if (!$singleUseToken) {
showIntroPage();
} else {
$tableTitle =
'Here's your <b>single use token:</b> <code>' . $singleUseToken .
'</code>' . "n" . '<br></code>';
// Show temp output until further development
echo $tableTitle;
}
}
/**
* Main logic. Take action based on the GET and POST
* parameters, which reflect whether the user has
* authenticated and which action they want to perform.
*/
if (count($_GET) == 1 && array_key_exists('token', $_GET)) {
showFirstAuthScreen();
} else {
if (count($_POST) == 0) {
showIntroPage();
} else {
//
}
}
?>
Page Information |
Wiki Information |
Recent PBwiki Blog Posts |