Part of the EllisLab Network
   
 
phpFlickr as a Library
Posted: 13 August 2007 11:29 AM   [ Ignore ]  
Summer Student
Total Posts:  1
Joined  08-13-2007

I’m new to CI and I’ve been fooling around with it. I really like what I see but i was wondering if I could get some help.

I’ve been trying to load the phpFlickr class as a lib and i keep on getting the “Unable to load the requested class: phpflickr”. It’s in the libraries folder. I’ve tried passing the params in different ways but no luck.

This is the way i’m loading it in my controller

$params = array('api_key' => '<MyAPI-KEY>', 'secret' => NULL, 'die_on_error' => 'false' );

        
$this->load->library('phpFlickr', $params);

Can anybody see what i’m doing wrong.

Thanks

Rik

Profile
 
 
Posted: 27 September 2007 07:59 AM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  87
Joined  08-23-2007

I had the same problem, but solved it by hardcoding my API-key in the class:

function phpFlickr ($api_key = ‘<MY API KEY>’, $secret = NULL, $die_on_error = false)

Not the most elegant way, but it works.

Also make sure the PEAR-library folder is in your libraries folder, otherwise phpFlickr won’t find it.

Profile
 
 
Posted: 02 May 2008 07:27 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  79
Joined  08-09-2007

after looking at this i still personally get the phpFlickr class to load

i get

An Error Was Encountered
Unable to load the requested class: phpflickr


I’ve hand coded my api into the class to see if that works with no joy

any ideas

Profile
 
 
Posted: 02 May 2008 07:54 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Rank
Total Posts:  79
Joined  08-09-2007

I forgot to put a capital letter on the front of the class

So it loads now but i’m not getting this.


Severity: Notice

Message: Undefined property: Flickr_test::$phpFlickr

Filename: controllers/flickr_test.php

Line Number: 18

Fatal error: Call to a member function photos_getRecent() on a non-object in /home/fhlinux162/o/our-atelier.co.uk/user/htdocs/application/controllers/flickr_test.php on line 18

I’m uing the example the phpFlickr gives

Profile
 
 
Posted: 06 May 2008 05:12 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  275
Joined  10-11-2007

in your controller are you calling a method from the library? If so, you’ll need to call it like so:

$this->phpflickr->photos_getRecent();

 Signature 

CI Bookmarks.

BarrettNewton.com

Profile
 
 
Posted: 06 May 2008 05:19 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  79
Joined  08-09-2007

yeah i am which is why its weird.

Profile
 
 
Posted: 06 May 2008 06:14 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  275
Joined  10-11-2007

Can you post your controller code, or PM it.

 Signature 

CI Bookmarks.

BarrettNewton.com

Profile
 
 
Posted: 07 May 2008 03:06 AM   [ Ignore ]   [ # 7 ]  
Grad Student
Rank
Total Posts:  79
Joined  08-09-2007

right it was because i was using so you were right ha ha ha wink

$this->phpFlickr->photos_getRecent();

instead of

$this->phpflickr->photos_getRecent();

Now thats working i’m not getting anything back at all which is now my next challange.

posted code

function index()
    
{
    $this
->load->library('phpFlickr');
    
    
$recent = $this->phpflickr->photos_getRecent();
    
print_r($recent);
    
    foreach (
$recent['photo'] as $photo) {
        $owner
= $this->phpflickr->people_getInfo($photo['owner']);
        echo
"<a href='http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'] . "/'>";
        echo
$photo['title'];
        echo
"</a> Owner: ";
        echo
"<a href='http://www.flickr.com/people/" . $photo['owner'] . "/'>";
        echo
$owner['username'];
        echo
"</a><br>";
    
}
    
    }

Its now throwing this error but i understand its because the foreach loop is empty


A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: controllers/flickr.php

Line Number: 20

Profile
 
 
Posted: 07 May 2008 04:27 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  275
Joined  10-11-2007

So nothing happens when you var_dump it… nothing’s returned?

I guess the first thing I’d try is running the library outside of CodeIgniter and see if I get any traction.

 Signature 

CI Bookmarks.

BarrettNewton.com

Profile
 
 
Posted: 05 September 2008 07:01 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  1
Joined  06-05-2007

I had almost the same problem… i just found out, that the $params are not given correctly.

So i tried this:

$params['api_key'] = '<MY_API_KEY>';
    
$params['secret'] = '<MY_SECRRET>';
    
$this->load->library('phpflickr');
    
$this->phpflickr->api_key = '<MY_API_KEY>';
    
$this->phpflickr->secret = '<MY_SECRET>';
    
$this->phpflickr->setToken('<MY_TOKEN>');
    
    
$this->phpflickr->enableCache(
        
"db",
        
"mysql://user:pass@localhost/phpflickr",
        
"600"
    
);


okey… i had to set the apikey and the secret twice… but this just works out fine for me. =)

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 64459 Total Logged-in Users: 18
Total Topics: 80973 Total Anonymous Users: 1
Total Replies: 435722 Total Guests: 241
Total Posts: 516695    
Members ( View Memberlist )
Active Members:    akkumaruCI andreacodec_frequencyCrucialDark PreacherDyaGaEthan DunhamGustavhjuekizm_i_nnokiapsiborgrogierbsalbertsonsmickiedooxweroYsekim