Jump to content

systomic26

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Everything posted by systomic26

  1. Ok I fixed that issue and a few others that came up afterward. Here is the updated code: <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_Query'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); // Traditional instantiation $gdClient = new Zend_Gdata(); $draft = new Zend_Gdata_App_Extension_Draft(); // Magic factory instantiation $gdClient = new Zend_Gdata(); $draft = $gdClient->newDraft(); // get feed $feed_url = "http://www.scripting.com/rss.xml"; function getFeed($feed_url) { $content = file_get_contents($feed_url); $xml = new SimpleXmlElement($content); $lis1 = (string) $xml->channel->item[0]->title; $lis2 = (string) $xml->channel->item[0]->description; $lis3 = (string) $xml->channel->item[0]->link; } // Log in to google api $user = 'EXAMPLE@gmail.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); // Create Blog Post function createPublishedPost($title = ' . $lis1 . ', $content = ' . $lis2 . ') { $gdClient = new Zend_Gdata(); $uri = 'http://www.blogger.com/post-create.g?blogID=SOME BLOG ID'; $entry = $gdClient->newEntry(); $entry->title = $gdClient->newTitle($title); $entry->content = $gdClient->newContent($content); $entry->content->setType('text'); $createdPost = $gdClient->insertEntry($entry, $uri); $idText = split('-', $createdPost->id->text); $newPostID = $idText[2]; return $newPostID; } getFeed($feed_url); createPublishedPost(); ?> OK now I'm getting this error message that I don't even know where to begin. Fatal error: Uncaught exception 'Zend_Gdata_App_Exception' with message 'DOMDocument cannot parse XML: DOMDocument::loadXML() [<a href='function.DOMDocument-loadXML'>function.DOMDocument-loadXML</a>]: Premature end of data in tag html line 2 in Entity, line: 338' in /home/rpfcoder/public_html/Zend/Gdata/App/FeedEntryParent.php:121 Stack trace: #0 /home/rpfcoder/public_html/Zend/Gdata/App.php(853): Zend_Gdata_App_FeedEntryParent->__construct('<!DOCTYPE HTML ...') #1 /home/rpfcoder/public_html/autoblog.php(60): Zend_Gdata_App->insertEntry(Object(Zend_Gdata_Entry), 'http://www.blog...') #2 /home/rpfcoder/public_html/autoblog.php(68): createPublishedPost() #3 {main} thrown in /home/rpfcoder/public_html/Zend/Gdata/App/FeedEntryParent.php on line 121
  2. Hey guys I pieced together this script to try and grab the first post in an rss feed and then create and publish a new blogger post with the title and description from rss feed. Here is the code. <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_Query'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); // Traditional instantiation $gdClient = new Zend_Gdata(); $draft = new Zend_Gdata_App_Extension_Draft(); // Magic factory instantiation $gdClient = new Zend_Gdata(); $draft = $gdClient->newDraft(); // get feed $feed_url = "some rss feed url"; function getFeed($feed_url) { $content = file_get_contents($feed_url); $xml = new SimpleXmlElement($content); $lis1 = (string) $xml->channel->item[0]->title; $lis2 = (string) $xml->channel->item[0]->description; $lis3 = (string) $xml->channel->item[0]->link; } // Log in to google api $user = 'example@gmail.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); // Create Blog Post function createPublishedPost($title = ' . $lis1 . ', $content = ' . $lis2 . ') { $gdClient = new Zend_Gdata(); $uri = 'http://www.blogger.com/post-create.g?blogID=Some Blog Id'; $entry = $gdClient->newEntry(); $entry->title = $gdClient->newTitle($title); $entry->content = $gdClient->newContent($content); $entry->content->setType('text'); $createdPost = $gdClient->insertEntry($entry, $uri); $idText = split('-', $createdPost->id->text); $newPostID = $idText[2]; return $newPostID; } getFeed($feed_url); createPublishedPost(); ?> It's spitting out this error. Fatal error: Uncaught exception 'Zend_Gdata_App_Exception' with message 'DOMDocument cannot parse XML: DOMDocument::loadXML() [<a href='function.DOMDocument-loadXML'>function.DOMDocument-loadXML</a>]: Premature end of data in tag html line 2 in Entity, line: 338' in /home/rpfcoder/public_html/Zend/Gdata/App/FeedEntryParent.php:121 Stack trace: #0 /home/rpfcoder/public_html/Zend/Gdata/App.php(853): Zend_Gdata_App_FeedEntryParent->__construct('<!DOCTYPE HTML ...') #1 /home/rpfcoder/public_html/autoblog.php(60): Zend_Gdata_App->insertEntry(Object(Zend_Gdata_Entry), 'http://www.blog...') #2 /home/rpfcoder/public_html/autoblog.php(68): createPublishedPost() #3 {main} thrown in /home/rpfcoder/public_html/Zend/Gdata/App/FeedEntryParent.php on line 121
  3. OK, I changed some stuff now I have this error message Notice: Undefined variable: gdClient in /home/rpfcoder/public_html/autoblog.php on line 45 Fatal error: Call to a member function newEntry() on a non-object in /home/rpfcoder/public_html/autoblog.php on line 45 Please, anyone that can shed some light on this.
  4. Currently this is giving me a blank screen. No error messages.
  5. sorry about that. It is first supposed to take an rss feed. Save xml tags <title>, <description>, <link> into strings. then it is supposed to login to google account. And post strings into a new blog post on blogger. Everything is divided into chunks that is commented above the code. If you need more detail please list some specific code examples and I'll tell you what it supposed to do. Basically when I run this script it will grab the first rss post from a specified feed then and use that data to automatically create and publish a new blog post on blogger.
  6. Does anyone see what's wrong with this script? <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_Query'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); // get feed $feed_url = "feed url"; function getFeed($feed_url) { $content = file_get_contents($feed_url); $xml = new SimpleXmlElement($content); $lis1 = (string) $xml->channel->item[0]->title; $lis2 = (string) $xml->channel->item[0]->description; $lis3 = (string) $xml->channel->item[0]->link; $lis4 = (string) $lis2 . '<br><a href="%s" title="%s">%s</a>',$lis3,$lis1,$lis1; } // Log in to google api $user = 'example@gmail.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); // Create Blog Post function createPublishedPost() { $uri = 'http://www.blogger.com/feeds/' . $blogID . '/posts/default'; $entry = $gdClient->newEntry(); $entry->title = $gdClient->newTitle($lis1); $entry->content = $gdClient->newContent($lis4); $entry->content->setType('html'); $createdPost = $gdClient->insertEntry($entry, $uri); $idText = split('-', $createdPost->id->text); $newPostID = $idText[2]; return $newPostID; } getFeed($feed_url); createPublishedPost(); ?> Your help would be greatly appreciated.
  7. I figured it out!! for anyone else that is interested here is the code: <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); $feed_url = "some feed url"; function getFeed($feed_url) { $content = file_get_contents($feed_url); $xml = new SimpleXmlElement($content); $lis1 = (string) $xml->channel->item[0]->title; $lis2 = (string) $xml->channel->item[0]->description; $lis3 = (string) $xml->channel->item[0]->link; printf('<a href="%s" title="%s">%s</a><br><br><p>%s</p>',$lis3,$lis1,$lis1,$lis2); } getFeed($feed_url); ?> Thanks for helping me figure this out.
  8. The feed url is: http://www.scripting.com/rss.xml
  9. That isn't working right. This script is not selecting the first <item> in the xml feed it is selective for the first <title>. This dispays the feed's name and description. I need it to display the first rss post on the list (the data found after the first <item> tag). I appreciate the suggestion though.
  10. Hey I was wandering if you guys could help me out with this. I'm kind of newbie so be patient please. It's supposed to take the first <item> from the specified rss feed and display it. <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); $feed_url = "some feed url"; function getFeed($feed_url) { $content = file_get_contents($feed_url); $x = new SimpleXmlElement(channel->item as $entry); $children = $x->children(); $entry = $children[0]; echo "<a href='$entry->link' title='$entry->title'>" . $entry->title . "</a><br><br><p>" . $entry->description . "</p>"; } getFeed($feed_url); ?> Somebody please help.
  11. so I guess it can't be done then?
  12. ok that worked kind of, when i run the script it displays the title of the rss feed. this is the first title xml tag. So I guess what I need is to get the second child, i guess. Is this possible?
  13. Hey all I got this script: $x = new SimpleXmlElement($content); foreach($x->channel->item as $entry) { echo "<a href='$entry->link' title='$entry->title'>" . $entry->title . "</a>"; } This should take an rss xml feed and save the title with a link to the original post as $entry. The problem is that instead of the foreach() function I need a function or a different way to do this that will just take the first item on the list. Please help this is driving me nuts.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.