akashrchandran / spotify-lyrics-api

A Rest API for fetching lyrics from Spotify which is powered by Musixmatch. Commandline version is available at akashrchandran/syrics.
http://github.akashrchandran.in/spotify-lyrics-api/
GNU General Public License v3.0
382 stars 28 forks source link

Error on Hosting the API #2

Closed robsw closed 2 years ago

robsw commented 2 years ago

/lyrics/index.php PHP Parse error: syntax error, unexpected ':', expecting ')' in /lyrics/index.php on line 24

akashrchandran commented 2 years ago

It seems that you might have edited the code, could you send screenshot of index.php at line 24.

robsw commented 2 years ago
image
akashrchandran commented 2 years ago

You're using older version of PHP, please upgrade to PHP version >= 8.1

robsw commented 2 years ago

Thanks, do you have an example of the config.json correct layout?

akashrchandran commented 2 years ago

The config.json is an auto generated cache file used to save token from spotify (they expire in an hour). You only need to set an environment variable SP_DC. SP_DC is cookie which is used to to authenticate against Spotify in order to have access to the required services. you can use this guide to find it.

https://github.com/akashrchandran/spotify-lyrics-api/blob/9dbb9de5be8105c3c4d7eb5f961d03db1c1ff34f/spotify.php#L9

akashrchandran commented 2 years ago

I will add deployment part to the documentation (README) soon. That will make it lot easier for peeps who want to host it themselves.

robsw commented 2 years ago

Thanks its generated a config.json with an accessToken but when i try to make a call with an ID or URL it says lyrics not available but they get found on your api.

akashrchandran commented 2 years ago

Have you set SP_DC, otherwise the generated token will be a anonymous token (not linked to an account). You can check by opening the config.json file and checking the value of isAnonymous key. for example if token is not linked to an account the isAnonymous will be True. image

If that's the case then check your SP_DC cookie and if it is correct, then delete the config.json file. It will make the script generate new token.

robsw commented 2 years ago

Ah thanks, I made a mistake setting up the environment variable, its all working now thank you so much!!!