• 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.
  • Posts

    • OK, back to normal now! Ozzy Osbourne - Flying High Again (Official Music Video)  
    • The actual download size is ~130–180 MB, not 100 MB.
    • Big change of pace for me! Gunnar & the Grizzly Boys - Standard American (Official)  
    • draw.io Desktop 30.2.4 by Razvan Serea draw.io desktop is a downloadable security-first diagramming application that runs on Windows, MacOS and Linux. Creating diagrams in the desktop app doesn’t need an internet connection. This is useful when you are disconnected or when you must create diagrams in a highly secure environment, where data protection is of the utmost importance. When you use the draw.io desktop app, your diagrams will be stored on your local device. Because this is a stand-alone application, also designed to run offline, there are no interfaces to cloud storage platforms available. Of course, you can still store your diagrams in folders that are synchronised to your cloud storage if you wish. Easy-to-use diagram editor The draw.io apps work just like the office and drawing tools you are used to using. Drag and drop shapes from the shape libraries and drag to draw connectors between them. Drag connectors to add waypoints and set a precise shape and position, or let them reroute automatically. Double click and start typing to add a label to anything. Create tables and swimlane flows with a familiar tool. Style shapes and connectors with customisable palettes, sketch options, fonts and text formatting tools. Search for shapes, including in open-source icon libraries. Use our vast libraries of shapes and templates, organised into logical categories, to create a range of diagrams and infographics. Generate diagrams from text descriptions using our smart templates. Diagram faster with keyboard shortcuts. draw.io Desktop 30.2.4 changelog: Uses electron 42.4.1 Updates to draw.io core 30.2.4. Download: draw.io 64-bit | Standalone ~100.0 MB (Open Source) Download: draw.io 32-bit | ARM64 | ARM64 Standalone Links: draw.io Home Page | Project page @GitHub | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Week One Done
      Eurosoft10 earned a badge
      Week One Done
    • One Month Later
      Eurosoft10 earned a badge
      One Month Later
    • One Year In
      Skeet Campbell earned a badge
      One Year In
    • One Month Later
      Sharbel earned a badge
      One Month Later
    • First Post
      BizSAR earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      591
    2. 2
      +Edouard
      191
    3. 3
      PsYcHoKiLLa
      81
    4. 4
      Michael Scrip
      77
    5. 5
      Steven P.
      73
  • Tell a friend

    Love Neowin? Tell a friend!