Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>OK. first of all futtta i had some problems with pecl and pear stuff. so i decided to stick with ZEND. I do appreciate you posting though, your code still helped me :-)....</p> <p>here is what i've got so far, taking some of the code from the ibm page posted above, but altering it to use oauth to get in. </p> <pre><code>&lt;?php session_start(); require_once 'common.php'; require_once 'Zend/Oauth/Consumer.php'; require_once 'Zend/Crypt/Rsa/Key/Private.php'; require_once 'Zend/Gdata.php'; require_once 'Zend/Gdata/Query.php'; $oauthOptions = array( 'requestScheme' =&gt; Zend_Oauth::REQUEST_SCHEME_HEADER, 'version' =&gt; '1.0', 'consumerKey' =&gt; 'PUT KEY HERE', 'consumerSecret' =&gt; 'PUT KEY HERE', 'signatureMethod' =&gt; 'HMAC-SHA1', 'requestTokenUrl' =&gt; 'https://www.google.com/accounts/OAuthGetRequestToken', 'userAuthorizationUrl' =&gt; 'https://www.google.com/accounts/OAuthAuthorizeToken', 'accessTokenUrl' =&gt; 'https://www.google.com/accounts/OAuthGetAccessToken' ); ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;Listing contacts&lt;/title&gt; &lt;style&gt; body { font-family: Verdana; } div.name { color: red; text-decoration: none; font-weight: bolder; } div.entry { display: inline; float: left; width: 400px; height: 150px; border: 2px solid; margin: 10px; padding: 5px; } td { vertical-align: top; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;? $consumer = new Zend_Oauth_Consumer($oauthOptions); if (!isset($_SESSION['ACCESS_TOKEN_GOOGLE'])) { if (!empty($_GET)) { $token = $consumer-&gt;getAccessToken($_GET, unserialize($_SESSION['REQUEST_TOKEN_GOOGLE'])); $_SESSION['ACCESS_TOKEN_GOOGLE'] = serialize($token); } else { $token = $consumer-&gt;getRequestToken(array('scope'=&gt;'http://www.google.com/m8/feeds')); $_SESSION['REQUEST_TOKEN_GOOGLE'] = serialize($token); $consumer-&gt;redirect(); exit; } } else { $token = unserialize($_SESSION['ACCESS_TOKEN_GOOGLE']); //$_SESSION['ACCESS_TOKEN_GOOGLE'] = null; } $http = $token-&gt;getHttpClient($oauthOptions); $gdata = new Zend_Gdata($http); $gdata-&gt;setMajorProtocolVersion(3); $gdata-&gt;getHttpClient()-&gt;setRequestScheme(Zend_Oauth::REQUEST_SCHEME_QUERYSTRING); $query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full?); //$query-&gt;setMaxResults(10); $feed = $gdata-&gt;getFeed($query); ?&gt; &lt;h2&gt;&lt;?php echo $feed-&gt;title; ?&gt;&lt;/h2&gt; &lt;div&gt; &lt;?php echo $feed-&gt;totalResults; ?&gt; contact(s) found. &lt;/div&gt; &lt;?php // parse feed and extract contact information // into simpler objects $results = array(); foreach($feed as $entry){ $xml = simplexml_load_string($entry-&gt;getXML()); $obj = new stdClass; $obj-&gt;name = (string) $entry-&gt;title; $obj-&gt;orgName = (string) $xml-&gt;organization-&gt;orgName; $obj-&gt;orgTitle = (string) $xml-&gt;organization-&gt;orgTitle; foreach ($xml-&gt;email as $e) { $obj-&gt;emailAddress[] = (string) $e['address']; } foreach ($xml-&gt;phoneNumber as $p) { $obj-&gt;phoneNumber[] = (string) $p; } foreach ($xml-&gt;website as $w) { $obj-&gt;website[] = (string) $w['href']; } $results[] = $obj; } ?&gt; &lt;?php // display results foreach ($results as $r) { ?&gt; &lt;div class="entry"&gt; &lt;div class="name"&gt;&lt;?php echo (!empty($r-&gt;name)) ? $r-&gt;name : 'Name not available'; ?&gt;&lt;/div&gt; &lt;div class="data"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Organization&lt;/td&gt; &lt;td&gt;&lt;?php echo $r-&gt;orgName; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Email&lt;/td&gt; &lt;td&gt;&lt;?php echo @join(', ', $r-&gt;emailAddress); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Phone&lt;/td&gt; &lt;td&gt;&lt;?php echo @join(', ', $r-&gt;phoneNumber); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Web&lt;/td&gt; &lt;td&gt;&lt;?php echo @join(', ', $r-&gt;website); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>There are still some problems, for me it only posts 25 results and i cannot seem to get setmaxresults to work... there seems to be problems with ZEND for that... if someone knows a work around, please post.</p> <p>b</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload