0
last.fmのプレイリストの1つにコマンドラインから「artist-song」エントリを追加しようとしています。Last.fm無効なメソッドシグネチャ(playlist.addTrack)
私はAPIキーを申請し、last.fm API documentationに記載されているようにセッションキーを取得しました。私はuser.getplaylist($ PLID)を使ってプレイリストIDを取得しました。
サービスでは、何かを書き込むメソッドのPOST要求としてクライアントにデータを送信する必要があります。
SERVICE=http://ws.audioscrobbler.com/2.0/
APIKEY=1dfdc3a278e6bac5c76442532fcd6a05 # mpc-last
SECRET=<md5hash: api secret>
LASTFM_USER=<string: myuser>
LASTFM_SK=<md5hash: valid session key>
# parameters (sorted alphabetically becasue method signature requires them to be)
# api_key (Required) : A Last.fm API key.
# api_sig (Required) : A Last.fm method signature. See authentication for more information.
# artist (Required) : The artist name that corresponds to the track to be added.
# method playlist.addTrack
# playlistID (Required) : The ID of the playlist - this is available in user.getPlaylists.
# sk (Required) : A session key generated by authenticating a user via the authentication protocol.
# track (Required) : The track name to add to the playlist.
METHOD=playlist.addtrack
ARTIST=prodigy
TRACK=breathe
PLID=8698647
MS="api_key${APIKEY}" # api_sig can't be here because it's not produced yet, obviously
MS="${MS}artist${ARTIST}" MS="${MS}method${METHOD}" MS="${MS}playlistid${PLID}" # tried with playlistID too
MS="${MS}track${TRACK}"
#MS="${MS}sk${LASTFM_SK}" # including this does not help
MS="${MS}${SECRET}"
# hash it
MS=`echo -n $MS | md5sum | cut -d' ' -f1`
# call the service.
# args also sorted alphabetically, but this should definitely not matter
curl \
-d api_key=${APIKEY} \
-d api_sig=${MS} \
-d artist=${ARTIST} \
-d method=${METHOD} \
-d playlistID=${PLID} \
-d sk=${LASTFM_SK} \
-d track=${TRACK} \
$SERVICE
は、それから私は、サービスを呼び出す:
$ ./add_track.sh
<?xml version="1.0" encoding="utf-8"?>
<lfm status="failed">
<error code="13">Invalid method signature supplied</error></lfm>