SHOW:
|
|
- or go back to the newest paste.
| 1 | /* | |
| 2 | * Copyright (C) 2013 Daniel Holm <[email protected]> | |
| 3 | * Victor Thompson <[email protected]> | |
| 4 | * | |
| 5 | * This program is free software; you can redistribute it and/or modify | |
| 6 | * it under the terms of the GNU General Public License as published by | |
| 7 | * the Free Software Foundation; version 3. | |
| 8 | * | |
| 9 | * This program is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | * GNU General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU General Public License | |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | */ | |
| 17 | ||
| 18 | - | // VARIABLES |
| 18 | + | |
| 19 | - | var api_key = "07c14de06e622165b5b4d55deb85f4da" |
| 19 | + | |
| 20 | - | var secret_key = "14125657da06bcb14919e23e2f09de32" |
| 20 | + | |
| 21 | - | var scrobble_urls = "https://ws.audioscrobbler.com/2.0/" // secure |
| 21 | + | |
| 22 | - | var scrobble_urlp = "http://ws.audioscrobbler.com/2.0/" // plain |
| 22 | + | |
| 23 | } | |
| 24 | - | // FUNCTIONS |
| 24 | + | |
| 25 | ||
| 26 | function request() {
| |
| 27 | var URL = "https://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=Kiss&api_key=07c14de06e622165b5b4d55deb85f4da"; | |
| 28 | ||
| 29 | var xhr = new XMLHttpRequest(); // create new XMLHttpRequest | |
| 30 | var encodedURL = encodeURIComponent(URL); // Make sure whatever you post is URI encoded | |
| 31 | xhr.open(TYPE, encodedURL, true); // only async supported | |
| 32 | xhr.send(); // send the data | |
| 33 | ||
| 34 | - | function request(URL,TYPE) {
|
| 34 | + | xhr.setRequestHeader("User-Agent", "Music-App/0.3");
|
| 35 | - | customdebug(URL); // print presentet URL |
| 35 | + | xhr.setRequestHeader('Content-Type', 'text/xml');
|
| 36 | - | customdebug(TYPE); // print presentet URL |
| 36 | + | |
| 37 | // did it work? | |
| 38 | if (xhr.readyState==4 && xhr.status === 200) {
| |
| 39 | customdebug("Response = " + xhr.responseText);
| |
| 40 | } | |
| 41 | ||
| 42 | else {
| |
| 43 | - | //xhr.setRequestHeader("User-Agent", "Music-App/"+appVersion);
|
| 43 | + | |
| 44 | - | //xhr.setRequestHeader('Content-Type', 'text/xml');
|
| 44 | + | |
| 45 | } | |
| 46 | ||
| 47 | return xhr.responseText; | |
| 48 | } |