2008年10月22日 星期三

[blogger tune up] Blogger Data API programming notes

Blogger Data API
Developer's Guide: PHP
http://code.google.com/apis/blogger/developers_guide_php.html

blogger.com feed tips
http://yukitowu.blogspot.com/2008/01/feed-blogger-hack.html



blogger new posts, setting the scheduled post date and categories
http://groups.google.com/group/bloggerDev/browse_thread/thread/a1eee09632f7eb9e

edit from Blogger.php (Zend's blogger example)
Add 2 functions
deleteAllPosts()
    public function deleteAllPosts()
    {
        $query = new Zend_Gdata_Query('http://www.blogger.com/feeds/' . $this->blogID . '/posts/default');
        $query->setParam('published-min', $startDate);
        $feed = $this->gdClient->getFeed($query);
        $this->deleteFeed($feed);
    }

deleteFeed($feed)
    public function deleteFeed($feed)
    {
        $i = 0;
        foreach($feed->entries as $entry)
        {
            echo "\t" . $i ." ". $entry->title->text . "\n<br>";
             
            $length = strlen($entry->id);
            $pos = strripos($entry->id, "-");
            $postID = substr($entry->id, $pos-$length+1);

            echo "\t" . $i ." ". $postID . "\n<br>";

            $uri = 'http://www.blogger.com/feeds/' . $this->blogID . '/posts/default/' . $postID;
            $this->gdClient->delete($uri); 
            
            $i++;
        }
    }

沒有留言: