The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 18, 2019, 12:35:28 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: flickr image grabber script  (Read 2592 times)
svakanda
Expert
****
Offline Offline

Posts: 131



View Profile
« on: December 25, 2008, 09:25:56 PM »

I'm trying to put together a short little script that allows me to feed it a single keyword, and it returns a hopefully relevant photo from flickr.  It works well as a simple call...but ideally I wanted to be able to integrate it into my wordpress.  Apparently that is going to be more difficult.  My wordpress has a 'custom' image field, and I haven't cracked it open to see how it processes it's input.  Thats the next plan, but I figured I'd mention what I was up to in case somebody has some relevant information.

here's the script, nothing fancy, uses phpFlickr

Code:
<?php
include "phpFlickr/phpFlickr.php";

$tags $_GET['tag'];
$api_key "";
$api_secret "";
$search_args = array ("tags"=>$tags,"tag_mode"=>"any");
$f = new phpFlickr($api_key);

$return $f->photos_search($search_args);

foreach (
$return['photo'] as $photo) {
        
$sum++;
        
$id $photo['id'];
        
$secret $photo['secret'];
        
$farm $photo['farm'];
        
$server $photo['server'];
        
$url "http://farm$farm.static.flickr.com/$server/$id"."_$secret.jpg";
        
$urls[] = $url;
/* Debugging Output
        echo "ID: ".$photo['id']."<br>";
        echo "SEC: ".$photo['secret']."<br>";
        echo "FARM: ".$photo['farm']."<br>";
        echo "SERV: ".$photo['server']."<br>";
        echo "URL: "."http://farm$farm.static.flickr.com/$server/$id"."_$secret.jpg"."<br>";
        echo "<br><br>";
*/
}

$grab $urls[rand(0,$sum)];
header("Location: $grab");
?>

Logged

a ship is safe in the harbor, but that's not what it's for.
patch
Rookie
**
Offline Offline

Posts: 32


View Profile
« Reply #1 on: February 15, 2009, 07:12:26 AM »

Hi there,

are you trying to insert images dynamically into your wp posts as they are displayed or trying a cron job to insert posts

or something else???
Logged
svakanda
Expert
****
Offline Offline

Posts: 131



View Profile
« Reply #2 on: February 15, 2009, 04:48:11 PM »

i was trying to dynamically display images as the post gets displayed...but in retrospect, i think a cron deal would be a lot easier on my server.
Logged

a ship is safe in the harbor, but that's not what it's for.
patch
Rookie
**
Offline Offline

Posts: 32


View Profile
« Reply #3 on: February 16, 2009, 01:19:43 AM »

did you get it sorted or are you still having problems?
Logged
svakanda
Expert
****
Offline Offline

Posts: 131



View Profile
« Reply #4 on: February 16, 2009, 05:24:40 AM »

it's all but abandoned really.  i did get it to work, but i had trouble getting very many accurate photos from flickr...could have probably done more with it.  but its null and void now.  thanks for checking!
Logged

a ship is safe in the harbor, but that's not what it's for.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!