Skip to content

Instantly share code, notes, and snippets.

@bryanbuchanan
Created April 23, 2013 01:52
Show Gist options
  • Save bryanbuchanan/5440211 to your computer and use it in GitHub Desktop.
Save bryanbuchanan/5440211 to your computer and use it in GitHub Desktop.
Takes a Flickr users's ID and finds their profile on Flickr.com
<?php
if (isset($_POST)) {
// Get user ID
$user_id = $_POST['user_id'];
// Data to send to Flickr API
$data = array(
"method" => "flickr.people.getInfo",
"user_id" => $user_id,
"api_key" => "FLICKR_API_KEY",
"format" => "json",
"nojsoncallback" => 1
);
// Send request to Flickr API
$request = curl_init("http://api.flickr.com/services/rest/");
curl_setopt($request, CURLOPT_POST, true);
curl_setopt($request, CURLOPT_POSTFIELDS, $data);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
$response = json_decode(curl_exec($request));
curl_close($request);
// Get profile page and forward
$flickr_page = $response->person->profileurl->_content;
header("Location: $flickr_page");
}
?>
<!doctype html>
<html>
<head></head>
<body>
<form action="" method="post">
<input type="text" name="user_id" placeholder="Flickr User ID">
<input type="submit" value="Find Flickr Profile">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment