int main()
{
spotipp::auth user("client id", "client secret");
std::string url = user.get_auth_token_url();
std::cout << "Please open the url -> " << url << "\n";
user.grab_auth_token();
std::cout << "Auth token: " << user.get_auth_token() << "\n";
user.grab_access_token();
std::cout << "Access token: " << user.get_access_token() << "\n";
spotipp::fetch::track specific_track = spotipp::fetch::get_track_from_id(user.get_access_token(), "2YzHSCRkNrOJmmYZ0HPBJJ");
std::cout << "track name: " << specific_track.name << "\n";
std::cout << "track's album: " << specific_track.album_name << "\n";
std::cout << "track's number in the album: " << specific_track.number << "\n";
std::cout << "track's popularity for the artist: " << specific_track.popularity << "\n";
spotipp::fetch::track current_song = user.get_current_track();
return 0;
}
``` im not sure about the way im doing things with the spotipp::fetch, any comments?
#spotify web api wrapper design questions
22 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
the idea behind this way of fetching songs is because in spotify you can fetch songs without logging it thru a user, a much simpler logging method to get access to basic spotify web api features
you probably also want to make it method of user, that just call fetch and pass his access token
also no error handling on all network resources, id recommend std::expected
common api, but you really need error handling on network
in real world program
off work i have non-published hex-chess app that have no any error handling, and also just getting server crash on game finish, so xD
user.fetch?
The thing that conflicts me is that you can also do certain stuff with the spotify web api without logging in like a regular user, using the whole server callback and so on, but just with a spotify dashboard application, so i feel like this method would allow for more freedom to pass whatever access token you want, instead of being forced to use the class provided and whatever
i could aswell keep on providing it, and also provide a method like user.get_track_from_id
like that yes, if you have circular dependency, somehow, then just use another cpp for that
just
spec_track user::fetch_track_by_id(id_type id_val) const
{
return fetch::fetch(this->get_access(),id_val);
}
hmm
keep method without user, just add capability to call it from user, without additional namespaces and arg
damn right you are
still, error handling, id recommend std::expected, or at least optional + last error
(last error (and errno) in general bad practice)
thanks for the ideas, really appreciate it
if you want it to see real world*
i'll work on all this, thanks a lot man
@compact cliff Has your question been resolved? If so, type !solved :)
!solve
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
!solved