Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <?php
  2.  
  3. //require_once __DIR__ . '/vendor/autoload.php';
  4.  
  5.  
  6. $user = 'xx@gmail.com';
  7. $pass = 'xx';
  8.  
  9. $blogID = '8229528821140778827';
  10.  
  11.  
  12.  
  13.  
  14.  
  15. require_once 'Zend/Loader.php';
  16. Zend_Loader::loadClass('Zend_Gdata');
  17. Zend_Loader::loadClass('Zend_Gdata_Query');
  18. Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
  19.  
  20. $blogUrl = 'http://losebellyfata.blogspot.com';
  21. $service = 'blogger';
  22.  
  23. global $gData, $gBlogId;
  24.  
  25. $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service, null,
  26. null, null, null,
  27. Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE');
  28.  
  29. function createPublishedPost($gData, $gBlogId, $myBlogTitle, $myBlogText)
  30. {
  31. $uri = 'https://www.blogger.com/feeds/' . $gBlogId . '/posts/default';
  32. $entry = $gData->newEntry();
  33. $entry->title = $gData->newTitle($myBlogTitle);
  34. $content = $gData->newContent($myBlogText);
  35. $content->setType('text');
  36. $entry->content = $content;
  37. $entryResult = $gData->insertEntry($entry, $uri);
  38. //$idText = split('-', $entryResult->id->text);
  39. //$newPostID = $idText[2];
  40. if (!empty($_SERVER['HTTP_REFERER'])) {
  41. header("Location: ".$_SERVER['HTTP_REFERER']);
  42. } else {
  43. header("location:*my_website_link*");
  44. }
  45. //return $newPostID;
  46. }
  47.  
  48. function getBlogId($gData, $feed)
  49. {
  50. $query = new Zend_Gdata_Query($feed);
  51. $feed = $gData->getFeed($query);
  52. preg_match('/blog-([0-9]+)/', $feed->id->text, $match);
  53. if (isset($match[1]))
  54. {
  55. return $match[1];
  56. }
  57. return false;
  58. }
  59. $gData = new Zend_Gdata($client);
  60. $gBlogId = getBlogId($gData, 'http://'.$blogUrl.'/feeds/posts/default');
  61. createPublishedPost($gData, $gBlogId, $blogTitle, $blogText);
  62.  
  63.  
  64.  
  65.  
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement