samwilson / phpflickr

A PHP wrapper for the Flickr API, including OAuth.

Home Page:https://packagist.org/packages/samwilson/phpflickr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The example script "recent_photos.php" requires the file config.php. Where is the config.php file located?

ElliotMcGucken opened this issue · comments

Thank you for the scripts.

The example script "recent_photos.php" requires the file config.php. Where is the config.php file located?

The code is unable to find the config.php in the directory tree of your installation.

I am also unable to find the config.php in the directory tree of your installation.

Where is the config.php file located?

Thank you!

As it says at the top of that file:

Before using this, you should use examples/get_auth_token.php to retrieve an access
token and add it to examples/config.php.

i.e. the examples/config.php doesn't exist, and you have to create it.

I'll update the docs to make it more clear.

Thanks for trying it out!

Thanks!

The get_auth_token.php script also requires the config.php file:

$configFile = DIR . '/config.php';
require_once $configFile;

So I need to create the config.php file? What should I put in it? Should it be blank? What should it look like?

Thanks!

I have added some more documentation, and an example config file.

Do these make it clearer?

By the way, you might be interested in the other thing I'm using this library for at the moment: a MediaWiki extension for importing Flickr photos into a wiki. My idea is to combine it with the Cargo extension for managing lots of photos.

Thanks Sam,

I just reinstalled your code again. You write, "To use these, first copy examples/config.dist.php to examples/config.php"

There is no config.dist.php in the examples folder. Here is my listing;

image

Could you please provide me a text example of what the config.dist.php should look like?

Or could you please let me know where I could find a copy?

What do I need to put in the config file? I have used many config files, but generally they are provided with the code.

Also, when I finally am able to run your test scripts, which directory should they be in?

Right now the test scripts are in this folder here:
/var/www/html/gnr/vendor/samwilson/phpflickr/examples

But when I run the scripts, in which directory should I put them in?

It would be nice (and fairly easy) to have the scripts run immediately after installation, so as to save everyone time. I would love to help you with this!

Thanks!

Oh, I do apologise, I thought you were just checking out this repository on it's own, and so would be using the master branch. The new file is not in any tagged release yet.

That said, you should not need to use the examples' config file in your own project. They're there just as hints to get you going with your own code — your project will have its own way of saving API keys and tokens. If it were to create a config file on installation (or update) then it'd be created in your config directory, and the examples wouldn't know where that is. Also, you shouldn't be moving the example script anywhere; they should just stay where they are.

I suggest you download the master branch of PhpFlickr and experiment with it on its own to start with, before trying to incorporate it into a project. The example scripts are of no use in a project; they're just a learning aid.

Thanks Sam,

How do I download the "master branch of PhpFlickr?" Where might I find it?

I am just trying to get a simple script working via the command line or browser using PhpFlick on a Centos linux server, so I can play and learn.

What would be the quickest way to get one of your example scripts running on my Centos server, so I can see it work via a browser or the command line?

What all must I install so as to get a simple working script which uses PhpFlickr?

Thanks Sam

So, probably a rough guide is something like the following:

git clone https://github.com/samwilson/phpflickr`
cd phpflickr/examples
cp config.dist.php config.php

Then edit examples/config.php to contain your own API key and secret (just those two for now).

At this point you should be able to run:

php unauthenticated_requests.php

Then run:

php get_auth_token.php

This will spit out the other two required variables for config.php, so you can copy and paste them there.

Now you should be able to run examples that require an authenticated request, such as

php recent_photos.php

Hope this helps!

Oh, sorry, forgot to add: after you clone the repo you need to run composer update when in the phpflickr/ directory.

Thanks so much Sam!

Your simple steps got me up and running, and I am now able to start playing around and working with other methods from the Flickr API!

I think a lot of folks will find your simple steps to be of great use. Thanks so much!

Hello Sam,

When I try to call the method flickr.photos.getRecent, using the line

$recent = $phpFlickr->photos_getRecent();

in your recent_photos.php code, I get an error stating:

PHP Fatal error: Uncaught Error: Call to undefined method Samwilson\PhpFlickr\PhpFlickr::photos_getRecent() in /var/www/html/11/phpflickr/examples/11recent_photos.php:40
Stack trace:
#0 {main}
thrown in /var/www/html/11/phpflickr/examples/11recent_photos.php on line 40

Are all the Flickr API methods defined in your code?

If not, which methods are not defined?

Thanks!

P.S. I get a similar error if I call the method flickr.photos.getPopular with the following line of code which I added to your recent_photos.php script:

$recent = $phpFlickr->photos_getPopular();

The error reads:

PHP Fatal error: Uncaught Error: Call to undefined method Samwilson\PhpFlickr\PhpFlickr::photos_getPopular() in /var/www/html/11/phpflickr/examples/11recent_photos.php:41
Stack trace:
#0 {main}
thrown in /var/www/html/11/phpflickr/examples/11recent_photos.php on line 41

I'm not sure how you're getting that error, there is no file examples/11recent_photos.php in PhpFlickr!

Is this a new file you're testing with? Can you post the whole code? I wonder if you're including vendor/autoload.php? Or perhaps something else is wrong.

11recent_photos.php is the same as your code recent_photos.php, but I just added one line:

$recent = $phpFlickr->photos_getRecent();

I added it right under your line, which I commented out as follows:

//$recent = $phpFlickr->photos_getContactsPhotos();

Can you call the method

$recent = $phpFlickr->photos_getRecent();

from your recent_photos.php script?

Good find! This is a regression bug. The correct method name for that is photosGetRecent(). I'll fix it up shortly, but will keep backwards compatibility. For now you should be able to use that.

This is fixed in current master. I'll prepare a release shortly.

Thanks Sam! It works now.

What are the best books, tutorials, and resources that would teach me more about the object-oriented PHP programming that your code uses?

Are there any tutorials about the classes and methods of the Flickr API?

Do you use the JSON structures in your code, as described here:
https://www.flickr.com/services/api/response.php.html
https://www.flickr.com/services/api/response.json.html

Thank you! Any hints as to what to study and read would be great!

Learning PHP is outside the scope of this project! ;-) But really, it's mostly a matter of finding a project that you wished existed and building it. All the things you need to know, you'll learn. :)

(Anyway, I'm calling this bug done for now; it's fixed in 4.3.0.)

I'm somewhat puzzled as to why recent_photos.php is being used as an example with authentication. The 2 calls used are flickr.photos.getRecent and flickr.people.getInfo and both of those do not require authentication according to the spec:

https://www.flickr.com/services/api/flickr.photos.getRecent.html
https://www.flickr.com/services/api/flickr.people.getInfo.html

Also, I've tried running this with bogus token/secrettoken and this appears to work. Unless I'm missing something?