Exemplo n.º 1
0
 protected function publishToSoundcloud(array $new_mp3s)
 {
     if (is_null(SC_TOKEN) && is_null(SC_TOKEN_SECRET)) {
         $soundcloud = new Soundcloud(SC_CONSUMER_KEY, SC_CONSUMER_SECRET);
         $token = $soundcloud->get_request_token('http://a.callback.url.com/');
         echo ">> Your SC_TOKEN is : " . $token['oauth_token'] . "\n";
         echo ">> Your SC_TOKEN_SECRET is : " . $token['oauth_token_secret'] . "\n";
         $login = $soundcloud->get_authorize_url($token['oauth_token']);
         echo ">> Please fill in the file, and visit {$login}\n";
         return;
     } else {
         $sc = new Soundcloud(SC_CONSUMER_KEY, SC_CONSUMER_SECRET, SC_TOKEN, SC_TOKEN_SECRET);
         foreach ($new_mp3s as $item) {
             /* @var $item SimplePie_Item */
             /* @var $mp3 SimplePie_Enclosure */
             $mp3 = $item->get_enclosure(0);
             $title = $item->get_title();
             echo "Publishing {$title}...\n";
             $filename = basename($this->getLinkFromItem($item));
             $post_data = array('track[title]' => $item->get_title(), 'track[asset_data]' => $filename, 'track[sharing]' => 'private', 'track[description]' => strip_tags($item->get_description()));
             $sc->upload_track($post_data);
         }
     }
 }
Exemplo n.º 2
0
                    $message = 'Something went wrong while talking to SoundCloud, please try again.';
                }
            } else {
                $message = 'Couldn\'t move file, make sure the temporary path is writable by the server.';
            }
        } else {
            $message = 'SoundCloud support .mp3, .aiff, .wav, .flac, .aac, and .ogg files. Please select a different file.';
        }
    }
} else {
    // This is the first step in the "OAuth dance" where we ask the visitior to authicate himself.
    $soundcloud = new Soundcloud($consumer_key, $consumer_secret);
    $token = $soundcloud->get_request_token($callback_url);
    $_SESSION['oauth_request_token'] = $token['oauth_token'];
    $_SESSION['oauth_request_token_secret'] = $token['oauth_token_secret'];
    $login = $soundcloud->get_authorize_url($token['oauth_token']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>SoundCloud PHP API Wrapper</title>
    <meta name="author" content="Anton Lindqvist" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset/reset-min.css" />
    <link rel="stylesheet" type="text/css" href="assets/css/style.css" />
</head>
<body>
    <div id="wrapper">