Greqo Demo: get blogger user blog list
Overview
The example below obtains a ClientLogin authorization token and then uses it to request the list of blogs affiliated with the current user.A live demo can be found here.
See this page for information on including the Greqo code library in your script.
Sample Code
<?php
// Request Authorization Token (redundant: request_blog_list method calls this)
$_HTML['stdout'] .= '<p>attempting to retrieve gdata auth token</p>';
if ( $GreqoBlogger->request_clientlogin_token($service='blogger', $force=1) )
{
$_HTML['stdout'] .= '<p class="success">token for user ' .$GreqoBlogger->email. ' retrieved</p>';
#$_HTML['stdout'] .= '<p class="success">token: ' .$_SESSION['GDATA']['auth_token']. '</p>';
$_FLAG['request_list'] = 1;
}
else
{
$_HTML['stdout'] .= '<p class="failure">unable to retrieve authentication token (devs have been notified)</p>';
}
// Request List
if ( $_FLAG['request_list'] )
{
if ( $_DATA['BLOG_LIST'] = $GreqoBlogger->request_blog_list() )
{
$_HTML['stdout'] .= '<p class="success">blog list retrieved (see below)</p>';
$list_array = print_r($_DATA['BLOG_LIST'], 1);
$_HTML['result'] .= "<pre>{$list_array}</pre>";
$_CSS['result_height'] = "height:240px;";
}
else
{
$_HTML['stdout'] .= '<p class="failure">request failed (devs have been notified)</p>';
}
}
?>
// Request Authorization Token (redundant: request_blog_list method calls this)
$_HTML['stdout'] .= '<p>attempting to retrieve gdata auth token</p>';
if ( $GreqoBlogger->request_clientlogin_token($service='blogger', $force=1) )
{
$_HTML['stdout'] .= '<p class="success">token for user ' .$GreqoBlogger->email. ' retrieved</p>';
#$_HTML['stdout'] .= '<p class="success">token: ' .$_SESSION['GDATA']['auth_token']. '</p>';
$_FLAG['request_list'] = 1;
}
else
{
$_HTML['stdout'] .= '<p class="failure">unable to retrieve authentication token (devs have been notified)</p>';
}
// Request List
if ( $_FLAG['request_list'] )
{
if ( $_DATA['BLOG_LIST'] = $GreqoBlogger->request_blog_list() )
{
$_HTML['stdout'] .= '<p class="success">blog list retrieved (see below)</p>';
$list_array = print_r($_DATA['BLOG_LIST'], 1);
$_HTML['result'] .= "<pre>{$list_array}</pre>";
$_CSS['result_height'] = "height:240px;";
}
else
{
$_HTML['stdout'] .= '<p class="failure">request failed (devs have been notified)</p>';
}
}
?>
CategoryGreqo
[There are no comments on this page]