을 나는 약간 오해의 소지가 스포티 파이 문서를 찾을 수 세션에 관해서. 나는 시행 착오와 인터넷 검색에서 문서보다는 오히려 발견 한 많은 것들이있다.
@Backer와 마찬가지로, ch API 버전을 1.3.0 이상으로 설정하십시오 (사용 가능한 경우). 이 기능을 사용하려면 Spotify를 다시 시작해야합니다..
그런 다음이 같은 세션 개체에 액세스 할 수 있습니다 (여기서, "세션"는 소문자를해야합니다) :
이
models.session.load('product','connection','device','user').done(function(s){
console.log('sess:',s)
});
사용자 개체는 이것의 일부가 될 것입니다,하지만 채워지지 않습니다 로드하지 않는 한 속성이 있습니다.
require([
'$api/models','$api/models#Session'
], function(models) {
app.user = {};
models.session.load('product','connection','device','user').done(function(sess){
sess.user.load('name', 'username', 'subscribed').done(function(user){
app.user.name = user.name; // string
app.user.username = user.username; // string
app.user.subscribed = user.subscribed; // boolean
});
app.user.connection = sess.connection; // string
app.user.country = sess.country; // string ISO-2
app.user.device = sess.device; // string
app.user.language = sess.language; // string ISO-2
app.user.product = sess.product; // string
});
});
전체 세션 개체 :
Session
_done: 65535
_listening: true
_ob: Object
_obcount: 1
_requestArgs: Array[0]
_requestName: "session_event_wait"
capabilities: Object
connecting: false
connection: "wlan"
country: "SE"
developer: true
device: "desktop"
incognito: false
language: "en"
online: true
product: "open"
resolution: 1
streaming: "enabled"
testGroup: 000
user: User
_done: 255
currentUser: true
identifier: "longcodehere"
image: "http://profile-images.scdn.co/artists/default/anotherlongcodehere"
images: Array[2]
name: "My Name"
subscribed: false
uri: "spotify:user:@"
username: "myusername"
__proto__: c
__proto__: c
다음 세션에서 속성과 사용자의 부분 집합을 검색하는 예입니다