tags:

views:

1362

answers:

1

How can I make a simple CURL request to that Flickr API that does the following:

Get the X number of most recent photos URLs + captions from collection Y?

Where "X" is the number of photo URLs and "Y" is the collection name.

This code is part of an existing application and I'm not allowed to use scripts like PHPFlickr for help.

+3  A: 

what is the problem of using a already tested PHP api, you probably will need care about lot of stuff as authentication, size, etc. doing that by your own

Edit:

I will put some simple code using curl. hope helps you. I grabbed the idea from here

<?php
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_URL, "http://api.flickr.com/services/feeds/groups_pool.gne?id=675729@N22&amp;lang=en-us&amp;format=json");
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
@curl_setopt($ch, CURLOPT_TIMEOUT, 10);

$response       = @curl_exec($ch);
$errno          = @curl_errno($ch);
$error          = @curl_error($ch);

if( $errno == CURLE_OK) {
    $pics = json_decode($response);
}

?>
Gabriel Sosa
I'm writing code that is part of another application. Although I would love to do it, I'm not permitted to use an existing tool like PHPFlickr.
I'm sorry, but if you are asking here about some "advice" about code and you use it, isnt the same as download the library, which is on "GNU Lesser General Public License" license and see how it works and then make your own code? regards
Gabriel Sosa
I've seen examples where JavaScript can be used to request JSON that contains the data I'm looking for. I was hoping that somebody knows a easy way to pull this simple data with CURL. This way, I don't have to spend all weekend trying to reverse engineer PHP Flickr :)
I just made an edit, my basic steps were setup curl in get mode and added a user-agent. saludos
Gabriel Sosa
Great! That did the trick. Now I will figure out how to specify a collection and I'm done.