本文整理汇总了PHP中Curl::getArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::getArray方法的具体用法?PHP Curl::getArray怎么用?PHP Curl::getArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curl
的用法示例。
在下文中一共展示了Curl::getArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nextSong
/**
* get the next song in the playlist
*/
private function nextSong()
{
$curl = new Curl();
$songArray = $curl->getArray("http://8tracks.com/sets/" . $this->playToken . "/next?mix_id=" . $this->mixId . "&api_version=2&format=jsonh");
$status = $songArray["status"];
if (!preg_match('/(200)/', $status)) {
if (preg_match('/(403)/', $status)) {
$this->output->error("8tracks made a boo boo. (" . $status . ")", 403);
} else {
$this->output->error("8tracks made a boo boo. (" . $status . ")");
}
}
if (isset($songArray["set"]["track"]["id"])) {
$songId = $songArray["set"]["track"]["id"];
$title = $songArray["set"]["track"]["name"];
$artist = $songArray["set"]["track"]["performer"];
$album = $songArray["set"]["track"]["release_name"];
$duration = $songArray["set"]["track"]["play_duration"];
$songUrl = $songArray["set"]["track"]["url"];
$song = $this->db->select("SELECT mixId FROM 8tracks_playlists_songs WHERE mixId=? AND songId=? LIMIT 1", array($this->mixId, $songId), array("%d", "%d"));
if (empty($song)) {
$this->db->insert("8tracks_playlists_songs", array("mixId" => $this->mixId, "songId" => $songId, "trackNumber" => $this->trackNumber), array("%d", "%d", "%d"));
$song = $this->db->select("SELECT songId FROM 8tracks_songs WHERE songId=? LIMIT 1", array($songId), array("%d"));
if (empty($song)) {
$this->db->insert("8tracks_songs", array("songId" => $songId, "title" => $title, "artist" => $artist, "album" => $album, "duration" => $duration, "songUrl" => $songUrl), array("%d", "%s", "%s", "%s", "%d", "%s"));
}
}
} else {
$this->output->error("That's all we could find.");
}
}
示例2: getNextSong
/**
* Get song info from URL.
*/
private function getNextSong()
{
// Grab song info.
$curl = new Curl();
$array = $curl->getArray("http://songza.com/api/1/station/" . $this->stationId . "/next", "sessionid=" . $this->sessionId . "; visitor-prompted:1");
// Clean up array.
$array = array("id" => $array["song"]["id"], "title" => $array["song"]["title"], "artist" => $array["song"]["artist"]["name"], "album" => $array["song"]["album"], "genre" => $array["song"]["genre"], "url" => $array["listen_url"], "coverUrls" => array("small" => $array["song"]["cover_url"], "medium" => $array["song"]["cover_url"], "large" => $array["song"]["cover_url"]), "duration" => $array["song"]["duration"]);
// Add to output array.
$this->outputArray["song"] = $array;
}