systomic26 Posted December 9, 2008 Share Posted December 9, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/ Share on other sites More sharing options...
akitchin Posted December 9, 2008 Share Posted December 9, 2008 for all we know, several hundred things COULD be wrong with that script, since we have no idea what it does, what it's supposed to do, and therefore what's wrong. we need some guidance. try telling us what it should be doing, what it's doing instead, and/or any PHP errors you're being given. Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/#findComment-710899 Share on other sites More sharing options...
CroNiX Posted December 9, 2008 Share Posted December 9, 2008 If it generates an error that would be helpful as well. Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/#findComment-710903 Share on other sites More sharing options...
systomic26 Posted December 9, 2008 Author Share Posted December 9, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/#findComment-710904 Share on other sites More sharing options...
akitchin Posted December 9, 2008 Share Posted December 9, 2008 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. okay, first step done: we know what it's SUPPOSED to do. so what's actually wrong with it? is it showing up blank? is it just not working? if it's not working, is it a complete failure, or does it manage some things but not others? Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/#findComment-710908 Share on other sites More sharing options...
systomic26 Posted December 10, 2008 Author Share Posted December 10, 2008 Currently this is giving me a blank screen. No error messages. Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/#findComment-711139 Share on other sites More sharing options...
systomic26 Posted December 10, 2008 Author Share Posted December 10, 2008 anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/#findComment-711165 Share on other sites More sharing options...
systomic26 Posted December 10, 2008 Author Share Posted December 10, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/#findComment-711178 Share on other sites More sharing options...
akitchin Posted December 10, 2008 Share Posted December 10, 2008 you're trying to call newEntry() on $gdClient from within another function, createPublishedPost(), where $gdClient will not exist. you either need to pass $gdClient to the outer function, or you need to globalize that variable. Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/#findComment-711479 Share on other sites More sharing options...
systomic26 Posted December 10, 2008 Author Share Posted December 10, 2008 you're trying to call newEntry() on $gdClient from within another function, createPublishedPost(), where $gdClient will not exist. you either need to pass $gdClient to the outer function, or you need to globalize that variable. 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 Quote Link to comment https://forums.phpfreaks.com/topic/136273-whats-wrong/#findComment-711861 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.