コード例 #1
0
ファイル: command-line.php プロジェクト: kidaa30/rdio-simple
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
require_once '../rdio.php';
require_once 'rdio-consumer-credentials.php';
# create an instance of the Rdio object with our consumer credentials
$rdio = new Rdio(array(RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET));
# authenticate against the Rdio service
$url = $rdio->begin_authentication('oob');
print "Go to: {$url}\n";
print "Then enter the code: ";
$verifier = trim(fgets(STDIN));
$rdio->complete_authentication($verifier);
# find out what playlists you created
$myPlaylists = $rdio->call('getPlaylists')->result->owned;
# list them
foreach ($myPlaylists as $playlist) {
    print $playlist->shortUrl;
    print "\t";
    print $playlist->name;
    print "\n";
}
コード例 #2
0
ファイル: hello.php プロジェクト: rdio/rdio-php
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

session_start(); 
require_once("rdio.php");

// basic API set up
define('CONSUMER_KEY', 'KEY');
define('CONSUMER_SECRET', 'SECRET');

$rdio = new Rdio(CONSUMER_KEY, CONSUMER_SECRET);

// work out our current URL.
$protocol = 'http';
if ($_SERVER['SERVER_PORT'] == 443 || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
  $protocol .= 's';
  $protocol_port = $_SERVER['SERVER_PORT'];
} else {
  $protocol_port = 80;
}
$host = $_SERVER['HTTP_HOST'];
$port = $_SERVER['SERVER_PORT'];
$request = $_SERVER['PHP_SELF'];
$query = substr($_SERVER['argv'][0], strpos($_SERVER['argv'][0], ';') + 1);
$BASEURL = $protocol . '://' . $host . ($port == $protocol_port ? '' : ':' . $port) . $request;
コード例 #3
0
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
session_start();
require_once '../rdio.php';
require_once 'rdio-consumer-credentials.php';
# create an instance of the Rdio object with our consumer credentials
$rdio = new Rdio(array(RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET));
# work out what our current URL is
$current_url = "http" . (!empty($_SERVER['HTTPS']) ? "s" : "") . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
if ($_GET['logout']) {
    # to log out, just throw away the session data
    session_destroy();
    # and start again
    header('Location: ' . $current_url);
}
if ($_SESSION['oauth_token'] && $_SESSION['oauth_token_secret']) {
    # we have a token in our session, let's use it
    $rdio->token = array($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
    if ($_GET['oauth_verifier']) {
        # we've been passed a verifier, that means that we're in the middle of
        # authentication.
        $rdio->complete_authentication($_GET['oauth_verifier']);