====== REST Authentication ====== Locked channels require client side authentication in order to reveal their playlists. For this you need to dynamically create a link to a specific channel resource. Below please find an PHP4 coding example which should also be easily transferable to other programming languages. \\ (more to come) get_url(); class feedbeat_auth { var $public_key = '47fc6879dade0'; var $secret_key = '33eb1c2440947275cb58c769fad171e8'; var $url = ''; var $time = 0; var $expires = 0; /* local authentication */ function feedbeat_auth($url, $expires) { $this->url = $url; $this->time = time() + $expires; $this->signature = rawurlencode($this->base64($this->hasher("$this->time\n$url", $this->secret_key))); return true; } function get_url() { return sprintf('%skeyid/%s/exp/%s/sig/%s/', $this->url, $this->public_key, $this->time, urlencode($this->signature)); } function get_array() { return array('keyid'=>$this->public_key,'exp'=>$this->time,'sig'=>$this->signature); } function hasher($data, $key) { // Algorithm adapted (stolen) from http://pear.php.net/package/Crypt_HMAC/) if(strlen($key) > 64) $key = pack("H40", sha1($key)); if(strlen($key) < 64) $key = str_pad($key, 64, chr(0)); $ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64)); $opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64)); return sha1($opad . pack("H40", sha1($ipad . $data))); } function base64($str) { $ret = ""; for($i = 0; $i < strlen($str); $i += 2) $ret .= chr(hexdec(substr($str, $i, 2))); return base64_encode($ret); } } ?>