PHP:
  1. <?php
  2. require_once('Zend/Gdata.php');
  3. require_once('Zend/Gdata/Query.php');
  4. require_once('Zend/Gdata/ClientLogin.php');
  5.  
  6. //向 Blogger发送文章,可自定义Tag
  7. class Blogger{
  8. private $gdClient;
  9. private $blogID;
  10.  
  11. public function __construct($mail, $password, $blogID){
  12. $service = 'blogger';
  13. $client = Zend_Gdata_ClientLogin::getHttpClient($mail, $password, $service);
  14. $this->gdClient = new Zend_Gdata($client);
  15. $this->blogID = $blogID;
  16. }
  17.  
  18. public function printAllBlogs(){
  19. $query = new Zend_Gdata_Query('https://www.blogger.com/feeds/default/blogs');
  20. $feed = $this->gdClient->getFeed($query);
  21. $this->printFeed($feed);
  22. }
  23.  
  24. public function printFeed($feed){
  25. $i = 0;
  26. foreach($feed->entries as $entry) {
  27. print_r (split('-', $entry->id->text));
  28. $i++;
  29. }
  30. }
  31.  
  32. public function createPublishedPost($title='Hello, world!', $content='I am blogging on the internet.', $category= '', $publish){
  33. $uri = 'https://www.blogger.com/feeds/' . $this->blogID . '/posts/default';
  34. $entry = $this->gdClient->newEntry();
  35. $entry->title = $this->gdClient->newTitle($title);
  36. $entry->content = $this->gdClient->newContent($content);
  37. $entry->published = $this->gdClient->newPublished($publish);
  38. if(preg_match('/,/s',$category)){
  39. $categorys = explode($category,',');
  40. }else{
  41. $categorys[] = $category;
  42. }
  43. $labels = array();
  44. foreach ($categorys as $key =>$value){
  45. $labels[] = new Zend_Gdata_App_Extension_Category($value, 'http://www.blogger.com/atom/ns#');
  46. }
  47.  
  48. $entry->setCategory($labels);
  49.  
  50. $entry->content->setType('text');
  51.  
  52. $createdPost = $this->gdClient->insertEntry($entry, $uri);
  53. $idText = split('-', $createdPost->id->text);
  54. $newPostID = $idText[2];
  55.  
  56. return $newPostID;
  57. }
  58.  
  59. }

: http://blog.dayuer.com/archives/2008/11/18/453.html

I want to say something ...

Login , Register