|
Posted by "M. Sokolewicz" on 01/14/06 20:26
Lists wrote:
> Hello List,
>
> I made something work, but probably in the most crappy way possible.
>
> My goal is to take just the HTML for the image and link from the Flickr
> badge js script.
>
> This is what I did, please help me do in a better way. I'd appreciate
> good sources to read to learn to strip stuff away and just get specific
> parts as well. I never know which of the str functions to use.
>
> <?
> // allow retrieval of external web source
> ini_set('allow_url_fopen',1);
>
> // get flickr js file
> $photo = file_get_contents("http://www.flickr.com/badge_code_v2.gne?
> count=1&display=latest&size=m&layout=h&source=user&user=91667218% 40N00");
>
> //get rid of all the crap except for the image tags
> $photo = strstr($photo, '<a');
> list($image, $trash) = explode("'", $photo);
> $image = ereg_replace("</td>","", $image);
> ?>
why not just do:
$file =
file_get_contents('http://www.flickr.com/badge_code_v2.gne?count=1&display=latest&size=m&layout=h&source=user&user=91667218%40N00');
preg_match('#<img (.*)src="(.+)"#U', $file, $r);
$photo = $r[2];
?
- tul
Navigation:
[Reply to this message]
|