<?php require '../src/Curl/Curl.php'; use ZzhhCurl\Curl; function construct_url($photo, $size = 's', $ext = 'jpg') { $url = 'http://farm' . $photo->farm . '.staticflickr.com/' . $photo->server . '/' . $photo->id . '_' . $photo->secret . '_' . $size . '.' . $ext; return $url; } define('FLICKR_API_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); $data = array('method' => 'flickr.photos.search', 'api_key' => FLICKR_API_KEY, 'text' => 'happy', 'sort' => 'interestingness-desc', 'safe_search' => '3', 'format' => 'json', 'nojsoncallback' => '1'); $curl = new Curl(); $curl->get('https://api.flickr.com/services/rest/', $data); foreach ($curl->response->photos->photo as $photo) { echo '<img alt="" src="' . construct_url($photo) . '" height="75" width="75" />'; }
$start = strpos($rawTextStuff, '<text>'); // Get the end position of the text tag. $end = strpos($rawTextStuff, '</text>'); // Check that the start and end positions were successfully retrieved. if ($start !== FALSE and $end !== FALSE) { $text = substr($rawTextStuff, $start + 6, $end - $start - 6); } else { $text = ''; } if ($doctype == 'witness' and $divtype == 'title') { echo "<br /><br /><span style='color: green; font-weight: bold;'>SKIPPING '" . $filename . "' (links to a .inc.php file and is not needed)</span>"; $not_needed++; continue; } // Determine the URL of the file on the website. $url = construct_url($filename, $divtype, $doctype); // Determine whether the requested URL exists. $code = get_response($url); // If response code is not 200 or 404, then we know there was a connection error. // If this is the case, then retry getting the document again. if ($code != '200' and $code != '404') { $code = get_response($url); } if ($code == '404') { echo "<br /><br /><span style='color: red; font-weight: bold;'>FAILED '" . $filename . "' (missing)</span>"; $missing_count++; continue; } elseif ($code != '200') { echo "<br /><br /><span style='color: red; font-weight: bold;'>FAILED '" . $filename . "' (could not connect to the server)</span>"; $connectivity_error++; continue;