session_destroy(); } // Change these four variables, note the that temporary path must be writable by the server. $consumer_key = 'your-consumer-key'; $consumer_secret = 'your-consumer-secret'; $callback_url = 'your-callback-url'; $tmp_path = '/absolute/path/to/directory/where/tracks/are/saved/temporary/'; // Variables used for verifying the status of the "OAuth dance". $oauth_token = isset($_GET['oauth_verifier']) ? $_GET['oauth_verifier'] : (isset($_SESSION['oauth_access_token']) ? $_SESSION['oauth_access_token'] : NULL); $oauth_request_token = isset($_SESSION['oauth_request_token']) ? $_SESSION['oauth_request_token'] : NULL; $oauth_request_token_secret = isset($_SESSION['oauth_request_token_secret']) ? $_SESSION['oauth_request_token_secret'] : NULL; if (isset($oauth_token) && isset($oauth_request_token) && isset($oauth_request_token_secret)) { // Retreive access tokens if missing. if (!isset($_SESSION['oauth_access_token']) && !isset($_SESSION['oauth_access_token_secret'])) { $soundcloud = new Soundcloud($consumer_key, $consumer_secret, $_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']); $token = $soundcloud->get_access_token($oauth_token); $_SESSION['oauth_access_token'] = $token['oauth_token']; $_SESSION['oauth_access_token_secret'] = $token['oauth_token_secret']; } // Construct a fully authicated connection with SoundCloud. $soundcloud = new Soundcloud($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); // Get basic info about the authicated visitor. $me = $soundcloud->request('me'); $me = new SimpleXMLElement($me); $me = get_object_vars($me); // If a track is submitted. if (isset($_POST['submit'])) { // We have to make sure it's a valid and supported format by SoundCloud. // Note that you also can include artwork for your tracks. Use the same // procedure as for the tracks. PNG, JPG, GIF allowed and a max size of 5MB. // The artwork field is called track[artwork_data].