Skip to content

Instantly share code, notes, and snippets.

View mager's full-sized avatar
🏠
Working from home

Mager mager

🏠
Working from home
View GitHub Profile
@mager
mager / spotify-apps-sandbox-share.html
Created February 11, 2012 22:51
Spotify Apps API - Show "Share" popup (HTML)
<div id="share"></div>
@mager
mager / spotify-apps-sandbox-share.js
Created February 11, 2012 22:50
Spotify Apps API - Show "Share" popup
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
/* The <div /> that will contain the popup */
var element = $('#share');
/* The Spotify URI of the content you want to share */
var content = 'spotify:track:76a6mUM5r7VPexAj37TLjo';
@mager
mager / spotify-apps-sandbox-creating_tabs.html
Created February 11, 2012 20:54
Spotify Apps API - Handling arguments and creating navigational tabs (HTML)
<div id="index">
<!-- This content will show up in the "Home" tab -->
</div>
<div id="tabs">
<!-- This content will show up in the "How to use tabs" tab -->
</div>
@mager
mager / spotify-apps-sandbox-creating_tabs.json
Created February 11, 2012 20:51
Spotify Apps API - Handling arguments and creating navigational tabs (manifest.json)
{
...
"DefaultTabs": [
{
"arguments": "index",
"title": {
"en": "Home"
}
},
{
@mager
mager / spotify-apps-sandbox-creating_tabs.js
Created February 11, 2012 20:38
Spotify Apps API - Handling arguments and creating navigational tabs
sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');
tabs(); // See function definition below
/* When a user clicks a tab, the "arguments" property on the
* Application object changes, and the tabs() function fires */
models.application.observe(models.EVENT.ARGUMENTSCHANGED, tabs);
function tabs() {
@mager
mager / spotify-apps-sandbox-player+list.js
Created February 11, 2012 18:01
Spotify Apps API - Play a list of songs (JS)
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
var views = sp.require("sp://import/scripts/api/views");
/* Create an array of tracks from the user's library */
var tracks = models.library.tracks;
/* Create a temporary playlist and fill it with tracks
* from the previous query */
@mager
mager / spotify-apps-sandbox-manifest.json
Created February 10, 2012 20:46
Spotify Apps API - Creating your manifest.json file
{
"AppDescription": {
"en": "A tutorial app for Spotify Apps API"
},
"AppIcon": {
"36x18": "tutorial.png"
},
"AppName": {
"en": "Spotify Sandbox"
},
@mager
mager / spotify-apps-sandbox-Facebook_get_listening_history.html
Created February 10, 2012 20:08
Spotify Apps API - Get a user's listening history from Facebook (HTML>
<ul id="listens"></ul>
@mager
mager / spotify-apps-sandbox-Facebook_get_listening_history.js
Created February 10, 2012 20:07
Spotify Apps API - Get a user's listening history from Facebook (JS)
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var auth = sp.require('sp://import/scripts/api/auth');
var permissions = ['user_actions.music'];
var app_id = '126891607432106';
var request_url = 'https://graph.facebook.com/me/music.listens';
auth.authenticateWithFacebook(app_id, permissions, {
onSuccess : function(accessToken, ttl) {
@mager
mager / spotify-apps-sandbox-Facebook_auth.html
Created February 10, 2012 19:57
Spotify Apps API - Authenticate with Facebook (HTML)
<div id="status">
<p>If you've successfully authenticated with Facebook, this should be your access token:</p>
</div>