edt
edt

Reputation: 22410

Using Flickr API + CURL to get image URL & Caption

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.

Upvotes: 1

Views: 5797

Answers (1)

Gabriel Sosa
Gabriel Sosa

Reputation: 7956

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&lang=en-us&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);
}

?>

Upvotes: 3

Related Questions