L-R
L-R

Reputation: 1232

query blogger posts with PHP, using search API

I'm using the BLogger API (google) to try and search for certain strings (i.e.'John Doe is my friend' - and return the blog id/url/etc) on public blogs. All I have found until now returns only data for my own account, not all public accounts.

Here's what I have now, it doesn't output much as I have no blogs set up myself. I've tried adding parameters and such to narrow down the search, but I feel the $query will need to change a bit.

<?php

$user = 'xxxxxx';
$pass = 'xxxxxx';

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Feed');

$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, 'blogger', null,
    Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null,
    Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE');
$gdClient = new Zend_Gdata($client);

function printAllBlogs(){
  $query = new Zend_Gdata_Query('http://www.blogger.com/feeds/default/blogs');
  $feed = $gdClient->getFeed($query);
  printFeed($feed);
}

function printFeed($feed){
  $i = 0;
  foreach($feed->entries as $entry) {
    print $i ." ". $entry->title->text . "\n";
    $i++;
  }
}

?>

I figure this shouldn't be too crazy...just haven't found a solution yet. Thanks!

Upvotes: 1

Views: 990

Answers (1)

Jorge Guberte
Jorge Guberte

Reputation: 11054

You say you're using the Blogger API, but for searching blogs you should use the Blog Search API, i think.

EDIT: It's only for Javascript, apparently...

Upvotes: 1

Related Questions