Articles Directory

  • 0

How To Remote Posting to Blogger using PHP Zend Framework

Here is a simple code for posting blog to blogger via PHP Zend Framework

  1. <?php
  2. require_once 'Zend/Loader.php';
  3. Zend_Loader::loadClass('Zend_Gdata');
  4. Zend_Loader::loadClass('Zend_Gdata_Query');
  5. Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
  6.  
  7. $user = [email protected]';
  8. $pass = 'password';
  9. $service = 'blogger';
  10.  
  11. $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service, null,
  12.         Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null,
  13.         Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE');
  14.        
  15. $gdClient = new Zend_Gdata($client);
  16.  
  17. $blogID = 'your blog id'; // like 98744313216546562
  18.  
  19. $title='Hello, world!',
  20. $content='I am blogging on the internet.'
  21.  
  22. $uri = 'http://www.blogger.com/feeds/' . $blogID . '/posts/default';
  23. $entry = $gdClient->newEntry();
  24. $entry->title = $gdClient->newTitle($title);
  25. $entry->content = $gdClient->newContent($content);
  26. $entry->content->setType('text');
  27.  
  28. $createdPost = $gdClient->insertEntry($entry, $uri);
  29. $idText = split('-', $createdPost->id->text);
  30. $newPostID = $idText[2];
  31.  
  32. echo $newPostID;
  33.  
  34. ?>
loading...

Related posts

Related posts