Here is a simple code for posting blog to blogger via PHP Zend Framework
- <?php
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass('Zend_Gdata');
- Zend_Loader::loadClass('Zend_Gdata_Query');
- Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
- $user = 'name@example.com';
- $pass = 'password';
- $service = 'blogger';
- $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service,null,
- Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null,
- Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE');
- $gdClient = new Zend_Gdata($client);
- $blogID = 'your blog id'; // like 98744313216546562
- $title='Hello, world!',
- $content='I am blogging on the internet.'
- $uri = 'http://www.blogger.com/feeds/' . $blogID . '/posts/default';
- $entry = $gdClient->newEntry();
- $entry->title = $gdClient->newTitle($title);
- $entry->content = $gdClient->newContent($content);
- $entry->content->setType('text');
- $createdPost = $gdClient->insertEntry($entry, $uri);
- $newPostID = $idText[2];
- echo $newPostID;
- ?>
0 komentar:
Posting Komentar