Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Changes homepage to your own in a Yahoo Pipe
Script for converting a Yahoo Pipe's homepage URL into something more sensible
Requires cURL to be enabled
// In the link
// the pipe ID is uCxBbzww3hGB9ClS6ycw5g (everything after _id= and before &_render
$pipe_id = '';
$home = ''; // Your homepage
$author = ''; // Your email address
// Pipes Request
$req = "$pipe_id&_render=php";
$ch = curl_init();
// set the url to fetch
curl_setopt($ch, CURLOPT_URL, $req);
// don't give me the headers just the content
curl_setopt($ch, CURLOPT_HEADER, 0);
// return the value instead of printing the response to browser
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$pipe = curl_exec($ch);
// remember to always close the session and free all resources
// Parse the serialized response
$info = unserialize($pipe);
$info = $info['value'];
// This makes sure that all pubDates have the timezone info
// API dates were lacking timezones
preg_match('/-[0-9]{4}$/', $info['pubDate'], $matches);
$offset = $matches[0];
header ("Content-Type:text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
// Make sure your server can handle the echo shortcut below
// Otherwise find `<?=` and replace with `<?php echo `
<rss version="2.0"><channel>
<title><?=$info['title']; ?></title><description><?=$info['description'];?></description>
<?php foreach ($info['items'] as $item) : ?>
<link><?=$item['link'];?></link><guid isPermaLink="true"><?=$item['guid'];?></guid>
<pubDate><?=$item['pubDate'];?><?php if (strpos($item['pubDate'], $offset) === false) { echo ' ' . $offset; } ?></pubDate>
<?php if (is_array($item['category'])) : ?>
<?php foreach ($item['category'] as $cat) : ?>
<?php endforeach; ?>
<?php elseif ($item['category']) : ?>
<?php endif; ?>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.