Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //require_once __DIR__ . '/vendor/autoload.php';
- $user = 'xx@gmail.com';
- $pass = 'xx';
- $blogID = '8229528821140778827';
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass('Zend_Gdata');
- Zend_Loader::loadClass('Zend_Gdata_Query');
- Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
- $blogUrl = 'http://losebellyfata.blogspot.com';
- $service = 'blogger';
- global $gData, $gBlogId;
- $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service, null,
- null, null, null,
- Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE');
- function createPublishedPost($gData, $gBlogId, $myBlogTitle, $myBlogText)
- {
- $uri = 'https://www.blogger.com/feeds/' . $gBlogId . '/posts/default';
- $entry = $gData->newEntry();
- $entry->title = $gData->newTitle($myBlogTitle);
- $content = $gData->newContent($myBlogText);
- $content->setType('text');
- $entry->content = $content;
- $entryResult = $gData->insertEntry($entry, $uri);
- //$idText = split('-', $entryResult->id->text);
- //$newPostID = $idText[2];
- if (!empty($_SERVER['HTTP_REFERER'])) {
- header("Location: ".$_SERVER['HTTP_REFERER']);
- } else {
- header("location:*my_website_link*");
- }
- //return $newPostID;
- }
- function getBlogId($gData, $feed)
- {
- $query = new Zend_Gdata_Query($feed);
- $feed = $gData->getFeed($query);
- preg_match('/blog-([0-9]+)/', $feed->id->text, $match);
- if (isset($match[1]))
- {
- return $match[1];
- }
- return false;
- }
- $gData = new Zend_Gdata($client);
- $gBlogId = getBlogId($gData, 'http://'.$blogUrl.'/feeds/posts/default');
- createPublishedPost($gData, $gBlogId, $blogTitle, $blogText);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement