I'm editing a Wordpress PHP Plugin to fit my site more specifically. It already makes posts to a site automatically as an RSS feed updates. I'm also working towards combining multiple feeds with Yahoo Pipes. Right now, giving the plugin the RSS that's been in use for a little while or a locally generated XML in the same format correctly makes the posts to the site. However, Yahoo Pipes after conversion doesn't do the trick.
The plugin is specifically for posting coupons. It creates a table.
$table_name = $wpdb->prefix . "couponfeeder"; $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, post_id text NOT NULL, couponid text NOT NULL, expdate text NOT NULL, image text NOT NULL, link text NOT NULL, cfdesc text NOT NULL, majcat text NOT NULL, mincat text NOT NULL, brand text NOT NULL, value text NOT NULL, UNIQUE KEY id (id));";
Then it gets the XML file from a URL and extracts values.
$xml = simplexml_load_file($url);
$size = sizeof($xml->item);
$coupon_count = 0;
for ($loop = 0; $loop < $size; $loop++) {
$couponid = $xml->item[$loop]->couponid;
$link = $xml->item[$loop]->link;
$description = htmlspecialchars($xml->item[$loop]->description, ENT_QUOTES);
$image = $xml->item[$loop]->image;
$activedate = $xml->item[$loop]->activedate;
$shutoff = $xml->item[$loop]->shutoff;
$expiration = $xml->item[$loop]->expiration;
$majorCategory = $xml->item[$loop]->majorCategory;
$minorCategory = $xml->item[$loop]->minorCategory;
$brand = htmlspecialchars($xml->item[$loop]->brand, ENT_QUOTES);
$value = $xml->item[$loop]->value;
$geotarget = $xml->item[$loop]->geotarget;
$sql = 'SELECT COUNT(*) FROM '.$wpdb->prefix.'couponfeeder WHERE couponid = '.$couponid;
$coupon_posted = $wpdb->get_var($wpdb->prepare($sql));
$exp_notime = reset(explode(' ', $expiration));
$exp_year = end(explode('/', $exp_notime));
$exp_month = reset(explode('/', $exp_notime));
$exp_day = array_search(1,array_flip(explode('/', $exp_notime)));
$exp_date = $exp_year.'-'.$exp_month.'-'.$exp_day;
$exp_timestamp = strtotime($exp_date);
It then makes some checks to see if a couponid is already in the system, appends the data to a post, and submits it.
So...
Yahoo Pipes automatically strips RSS tags to conform it to standards, so I'm outputting it as serialized PHP then converting it with PEAR XML Serializer.
$url = 'http://pipes.yahoo.com/pipes/pipe.run?_id=..............&_render=php';
$response = file_get_contents($url);
if ($response === false) {
die('Request failed');
}
// Convert serialized PHP to XML
$phpobj = unserialize($response);
$xmlobj = $this->array_to_xml($phpobj);
function array_to_xml($array) {
$options = array (
'addDecl' => TRUE,
'encoding' => 'iso-8859-1',
'indent' => ' ',
'rootName' => 'coupons',
'mode' => 'simplexml',
'defaultTagName' => 'item'
);
$serializer = new XML_Serializer($options);
if ($serializer->serialize($array)) {
return $serializer->getSerializedData();
}
else {
return null;
}
}
And then there's a block of preg_replace() and str_replace() functions that hack up the resulting XML to get it in exactly the same format as the originally used RSS. But the new resulting $xml value does not get the plugin to post.
Any thoughts on what in the conversion might be preventing this?

New Topic/Question
Reply



MultiQuote





|