Exemple #1
0
 private function getWikiText($wikiUrlTitle, $section = null)
 {
     $curl = new CurlCall();
     $urlSection = null == $section ? '' : '&rvsection=' . $section;
     $method = "wiki.query.title";
     $url = 'http://' . $this->conf['WIKI_DOMAIN'] . $this->conf['WIKI_API'] . '?format=php&action=query&rvprop=content&prop=revisions&redirects=1' . $urlSection . '&titles=' . $wikiUrlTitle;
     $result = $curl->getFromPhpSource($url, array('cache-ident' => $method, 'cache-time' => $this->conf['WIKI_CACHE_TIME'], 'user-agent' => 'WikiSlurp (http://github.com/NeilCrosby/wikislurp)'));
     $wikiText = false;
     if ($this->getDataFromArray($result, array('query', 'pages')) && !$this->getDataFromArray($result, array('query', 'pages', -1))) {
         $page = array_shift($result['query']['pages']);
         $wikiText = array_shift($page['revisions'][0]);
     }
     return $wikiText;
 }
    }
}
$tmpl = file_get_contents($file);
$tmpl = str_replace('%%hated%%', htmlentities($hatedNoUnderscore), $tmpl);
$annoyingHtml = getHtmlAnnoyingAndLovely($aYes, $nYesToShow, $aNo, $nNoToShow);
$tmpl = str_replace('%%annoying-things%%', $annoyingHtml, $tmpl);
// now we do the flickr image stuff
$temp = $hated;
$urlHated = urlencode($temp);
$curl = new CurlCall();
$imgAttribution = '';
$imgUrl = '';
$imgLink = '';
$method = 'flickr.photos.search';
$url = "{$imgApiBaseUrl}&method={$method}&text=\"{$urlHated}\"&sort=relevance&safe_search=1&media=photos&per_page=1";
$result = $curl->getFromPhpSource($url, array('cache-ident' => $method));
// if we didn't find an image, try again with a different search
if (!getDataFromArray($result, array('photos', 'photo', '0'))) {
    $method = 'flickr.photos.search';
    $url = "{$imgApiBaseUrl}&method=flickr.photos.search&text={$urlHated}&sort=relevance&safe_search=1&media=photos&per_page=1";
    $result = $curl->getFromPhpSource($url, array('cache-ident' => $method));
}
if ($img = getDataFromArray($result, array('photos', 'photo', '0'))) {
    // lets try and get some info about the specific user
    $method = 'flickr.people.getInfo';
    $url = "{$imgApiBaseUrl}&method={$method}&user_id={$img['owner']}";
    $result = $curl->getFromPhpSource($url, array('cache-ident' => $method));
    $ownerHtml = $img['owner'];
    if (isset($result['person'])) {
        $profileUrl = $result['person']['profileurl']['_content'];
        $profileUser = $result['person']['username']['_content'];