• 0

[php] Simplepie & Picasa Webalbums.


Question

Well, since google's embedding feature on picasa web albums links to their own website and i'd quite like to keep my own branding I used the simplepie php parser to use their RSS feed.

This might be really obvious and i'm probably being stupid, but I got it working so that it returns the link for each photo in an IMG tag quite happily.

<img src="https://lh4.google.com/image/MaxAWoolf/RnJQiIcFy0I/AAAAAAAAAQI/LeZIkAZlJIs/view4.jpg" alt="A Picture" width="512" height="512"/>

And I know the links work, because when you put them in the address bar it prompts you to download them, but the picture doesn't load and it just shows me the alt text!

Help me!!

Link to comment
https://www.neowin.net/forum/topic/568974-php-simplepie-picasa-webalbums/
Share on other sites

9 answers to this question

Recommended Posts

  • 0

The prompting to download part is the problem. The browser doesn't want to display them normally because they have content-disposition headers, so to get it to work you'll have to find another link for the photo.. that doesn't have this header attached to it.

Scott

  • 0

Hope this helps....

Save As DisplayPic.php

<?php
$picture = $_GET['googlepic'];
$ch = curl_init("$picture");
curl_setopt( $ch, CURLOPT_USERAGENT, "Internet Explorer" );
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
curl_exec($ch);
curl_close($ch);
?>

USAGE:

<p>
<img border="0"
src="https://your-server/displaypic.php?googlepic=http://lh4.google.com/image/MaxAWoolf/RnJQiIcFy0I/AAAAAAAAAQI/LeZIkAZlJIs/view4.jpg" width="512" height="512">
</p>

SilverB.

Quick and dirty, but should work!!!

:shiftyninja:

  • 0

You don't have cURL installed, try this.

demo.php

<?php
require_once('class.NamespaceNulledXMLDocument.php');
$sData = @file_get_contents('localFeed.xml');
$oDocument = simplexml_import_dom( new NamespaceNulledXMLDocument( $sData ) );
echo sprintf("<h1>Album %s by %s</h1>\r\n",(String)$oDocument->name,(String)$oDocument->user);
echo "<hr />\r\n";
foreach ($oDocument->entry as $oEntry)
{
	echo sprintf("<h2>%s</h2>\r\n",(String)$oEntry->title);
	echo '<ul>';
	echo sprintf("<li>%s: %s</li>\r\n",'Height',(Integer)$oEntry->height);
	echo sprintf("<li>%s: %s</li>\r\n",'Width',(Integer)$oEntry->width);
	echo sprintf("<li>%s: %s bytes.</li>\r\n",'Size',(Integer)$oEntry->size);
	echo "</ul>\r\n";
	echo sprintf('<img src="picasaImage.php?picasaImage=%s" alt="%s" />',base64_encode((String)$oEntry->content['src']),(String)$oEntry->title);
}
?>

picasaImage.php

<?php
if( isset($_GET['picasaImage']) )
{
	$sImageURL = base64_decode( $_GET['picasaImage'] );
	if( $sImageData = @file_get_contents($sImageURL) )
	{
		header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
		header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
		header( 'Content-Type: image/jpg' );
		header( 'Cache-Control: no-store, no-cache, must-revalidate' );
		header( 'Cache-Control: post-check=0, pre-check=0', false );
		header( 'Pragma: no-cache' );
		echo $sImageData;
		exit;
	}
}
exit;
?>

Place both of those on your server, it should do the trick.

SilverB.

Edited by SilverBulletUK
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.