0
我想根據這個授權Spotify的網絡API: https://developer.spotify.com/web-api/authorization-guide/Spotify的網絡API授權
但是,我得到了以下錯誤:
search.component.ts(18,5):提供參數不匹配,調用對象的
的任何簽字這是我search.component文件:
import { Injectable } from '@angular/core';
import { Http, Headers, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class SpotifyService {
private searchUrl: string;
private redirect_uri:string;
private client_id ='f716e056b5944d9bba2340802a7f88be';
private client_secret = 'acac31590ceb4da38a123253a8c87cc9';
private access_token:string;
private encoded = btoa(this.client_id + ':' + this.client_secret);
constructor(private http: Http) { }
getToken(){
let params = ('grant_type=client_credentials');
let headers = new Headers();
headers.append('Authorization', 'Basic ' + this.encoded);
headers.append('Content-Type' , 'application/x-www-form-urlencoded');
return this.http.post('https://accounts.spotify.com/api/token', params , {headers : headers})
.map(res=> res.json());
}
searchMusic(str: string, type = "artist", token: string){
this.searchUrl = 'https://api.spotify.com/v1/search?query=' + str + '&offset=0&limit=20&type=' + type + '&market=US';
let headers = new Headers();
headers.append('Authorization' , 'Bearer ' + token);
return this.http.get(this.searchUrl, {headers: headers})
.map((res: Response) => res.json());
}
}
謝謝你們在advanc即
第18行有一個明顯的問題需要修復。 –
對於不清楚的問題,我很抱歉。我只想問我的Spotify Web API授權解決方案是否正確。你怎麼看呢? –
這可能是最好的問題:[Code Review Stack Exchange](https://codereview.stackexchange.com/) –