Example #1
0
 public function __construct(Request $request)
 {
     $this->xmlResponse = CurlCall::call($request);
     if (!$this->isStatusOk()) {
         throw new \Exception(sprintf('The AdobeConnect\'s Server is returning an invalid status code.
             Request: %s
             Response: %s', preg_replace('/password\\=(.*)&/', 'password=***', $request->getUrl()), json_encode($this->xmlResponse)));
     }
 }
Example #2
0
 private function getWikiHtml($wikiText)
 {
     $curl = new CurlCall();
     $method = "wiki.parse";
     $url = 'http://' . $this->conf['WIKI_DOMAIN'] . $this->conf['WIKI_API'];
     $result = $curl->getFromPhpSourceAsPost($url, array('post-fields' => array("format" => 'php', 'action' => 'parse', 'text' => $wikiText), 'cache-ident' => $method, 'cache-time' => $this->conf['WIKI_HTML_CACHE_TIME'], 'user-agent' => 'WikiSlurp (http://github.com/NeilCrosby/wikislurp)'));
     if ($wikiText = $this->getDataFromArray($result, array('parse', 'text', '*'))) {
         return $wikiText;
     }
     return false;
 }
        $file = 'includes/no.tmpl';
        foreach ($aNo as $item) {
            if ($closestNo == getDataFromArray($item, array('title'))) {
                $currentDescription = getDataFromArray($item, array('description'));
            }
        }
    }
}
$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';
Example #4
0
 function getPlaylist($track, $artist, $numTracksRequired = 10)
 {
     $url = LAST_FM_API_URL . '?method=track.getinfo&artist=' . urlencode($artist) . '&track=' . urlencode($track) . '&api_key=' . LAST_FM_API_KEY;
     $curl = new CurlCall();
     $data = $curl->getFromXmlSource($url);
     $item = $data->track;
     $isStreamable = $item->streamable;
     $isFullTrack = 0;
     foreach ($item->streamable->attributes() as $key => $value) {
         if ('fulltrack' == $key) {
             $isFullTrack = $value;
         }
     }
     if ($isStreamable && $isFullTrack) {
         $playlist = array($data->track);
     }
     for ($i = 0; $i < $numTracksRequired - 1; $i++) {
         $chooseFrom = array();
         $url = LAST_FM_API_URL . '?method=track.getsimilar&artist=' . urlencode($artist) . '&track=' . urlencode($track) . '&api_key=' . LAST_FM_API_KEY;
         //error_log($url);
         $data = $curl->getFromXmlSource($url);
         //error_log(print_r($data, true));
         $bestMatch = $data->similartracks->track[0]->match;
         foreach ($data->similartracks->track as $item) {
             $isStreamable = $item->streamable;
             $isFullTrack = 0;
             foreach ($item->streamable->attributes() as $key => $value) {
                 if ('fulltrack' == $key) {
                     $isFullTrack = $value;
                 }
             }
             if (!$isStreamable || !$isFullTrack) {
                 continue;
             }
             if ($this->isSongAlreadyInPlaylist($item, $playlist)) {
                 continue;
             }
             if ($item->match < 0.85 * $bestMatch) {
                 break;
             }
             // make an extra request if we don't know how long the track is
             if (!$item->duration) {
                 $url = LAST_FM_API_URL . '?method=track.getinfo&artist=' . urlencode($item->artist->name) . '&track=' . urlencode($item->name) . '&api_key=' . LAST_FM_API_KEY;
                 $data = $curl->getFromXmlSource($url);
                 $item->addChild('duration', (string) $data->track->duration);
             }
             array_push($chooseFrom, $item);
         }
         if (0 == sizeof($chooseFrom)) {
             foreach ($data->similartracks->track as $item) {
                 if (!$this->isSongAlreadyInPlaylist($item, $playlist)) {
                     //error_log("pushed from the topish - {$item->artist->name} - {$item->name} - {$item->match}");
                     $isStreamable = $item->streamable;
                     $isFullTrack = 0;
                     foreach ($item->streamable->attributes() as $key => $value) {
                         if ('fulltrack' == $key) {
                             $isFullTrack = $value;
                         }
                     }
                     if ($isStreamable && $isFullTrack) {
                         array_push($playlist, $item);
                         break;
                     }
                 }
             }
         } else {
             array_push($playlist, $chooseFrom[array_rand($chooseFrom)]);
         }
         $artist = $playlist[sizeof($playlist) - 1]->artist->name;
         $track = $playlist[sizeof($playlist) - 1]->name;
     }
     return $playlist;
 }
 private function getWikiHtml($wikiText)
 {
     $curl = new CurlCall();
     $method = "wiki.parse";
     $url = 'http://' . $this->conf['WIKI_DOMAIN'] . $this->conf['WIKI_API'];
     $result = $curl->getFromPhpSourceAsPost($url, array('post-fields' => "format=php&action=parse&text=" . urlencode($wikiText), 'cache-ident' => $method, 'cache-time' => $this->conf['WIKI_HTML_CACHE_TIME']));
     if ($wikiText = $this->getDataFromArray($result, array('parse', 'text', '*'))) {
         return $wikiText;
     }
     return false;
 }