Office365 API - Pulling my userphoto - office365api

I have a simple web app that for the past month or so the following was working:
outlook.office365.com/api/beta/Me/userphotos('120x120')/$value
but now it returns:
{"error":{"code":"RequestBrokerOld-ParseUri","message":"Resource not found for the segment 'userphotos'."}}
I get the same error if I try any of the following:
https://outlook.office365.com/api/beta/Me/userphoto
https://outlook.office365.com/api/beta/Me/userphotos
https://outlook.office365.com/api/beta/Me/userphoto/$value
It is possible that my organisation has changed something to cause this? Or has there been a general change in how this request works?
In the same app, my other email and calendar requests all work fine, this is simply just a cosmetic problem of not displaying the users profile pic in the top corner.

This is really ElioStruyf's answer.
The endpoint is now called "photo" and not "userphoto"
To get the photo information you use:
https://outlook.office365.com/api/beta/Me/photo
To get the photo you call
https://outlook.office365.com/api/beta/Me/photo/$value
To get list of all available photo sizes, use this API endpoint -
https://outlook.office.com/api/beta/me/Photos/
Sample response -
{
"#odata.context": "https://outlook.office.com/api/beta/$metadata#Me/Photos",
"value": [
{
"#odata.id": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('48X48')",
"#odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('48X48')",
"#odata.mediaContentType": "image/jpeg",
"#odata.mediaEtag": "\"7A1F3A9D\"",
"Id": "48X48",
"Height": 48,
"Width": 48
},
{
"#odata.id": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('64X64')",
"#odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('64X64')",
"#odata.mediaContentType": "image/jpeg",
"#odata.mediaEtag": "\"7A1F3A9D\"",
"Id": "64X64",
"Height": 64,
"Width": 64
},
{
"#odata.id": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('96X96')",
"#odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('96X96')",
"#odata.mediaContentType": "image/jpeg",
"#odata.mediaEtag": "\"7A1F3A9D\"",
"Id": "96X96",
"Height": 96,
"Width": 96
},
{
"#odata.id": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('120X120')",
"#odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('120X120')",
"#odata.mediaContentType": "image/jpeg",
"#odata.mediaEtag": "\"7A1F3A9D\"",
"Id": "120X120",
"Height": 120,
"Width": 120
},
{
"#odata.id": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('240X240')",
"#odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('240X240')",
"#odata.mediaContentType": "image/jpeg",
"#odata.mediaEtag": "\"7A1F3A9D\"",
"Id": "240X240",
"Height": 240,
"Width": 240
},
{
"#odata.id": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('360X360')",
"#odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('360X360')",
"#odata.mediaContentType": "image/jpeg",
"#odata.mediaEtag": "\"7A1F3A9D\"",
"Id": "360X360",
"Height": 360,
"Width": 360
},
{
"#odata.id": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('432X432')",
"#odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('432X432')",
"#odata.mediaContentType": "image/jpeg",
"#odata.mediaEtag": "\"7A1F3A9D\"",
"Id": "432X432",
"Height": 432,
"Width": 432
},
{
"#odata.id": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('504X504')",
"#odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('504X504')",
"#odata.mediaContentType": "image/jpeg",
"#odata.mediaEtag": "\"7A1F3A9D\"",
"Id": "504X504",
"Height": 504,
"Width": 504
},
{
"#odata.id": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('648X648')",
"#odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe#contoso.com')/Photos('648X648')",
"#odata.mediaContentType": "image/jpeg",
"#odata.mediaEtag": "\"7A1F3A9D\"",
"Id": "648X648",
"Height": 648,
"Width": 648
}
]
}
To fetch actual blob of desired photo size, call this API -
https://outlook.office.com/api/beta/me/Photos('120X120')/$value

Nothing's wrong with your organization's office 365 configuration. Outlook UserPhoto API has stopped working with the given endpoint. Unfortunately, they haven't updated the documentation yet. Let's hope it will be up soon or they will at least update documentation with new API endpoint.

Related

Youtube API Playlists not returning the Playlist

I am using the Playlists endpoint of Youtube's API to get the playlists from a specific channel but it doesn't work for the following channels:
https://www.youtube.com/channel/UCX5fyLRcU05DMa2OVu-qFEQ
https://www.youtube.com/channel/UCwm2mdiUXApmL5bCxHtgJIA
The query I am using:
https://www.googleapis.com/youtube/v3/playlists?channelId=UCwm2mdiUXApmL5bCxHtgJIA&part=snippet&order=date&maxResults=50&key=YOUR_API_KEY
https://www.googleapis.com/youtube/v3/playlists?channelId=UCX5fyLRcU05DMa2OVu-qFEQ&part=snippet&order=date&maxResults=50&key=YOUR_API_KEY
It doesn't return the videos when I try to target the playlists in these channels using the specif Playlist ID as well. I can see that these channels, playlists and videos are public and searchable.
Is there any reason why the API shouldn't return this playlist that I am missing?
Thank you for your help.
Bartu
If you check the playlist page of the channel you provided, you'll see that all playlists posted there are not really from the channel - those were added/generated by YouTube itself.
Example:
https://www.youtube.com/playlist?list=OLAK5uy_nvZSUlZB8qwifPgIVCoEulF4VyErdBX48
A normal playlist (that belongs to the channel) should have its ID as follows:
PL3tRBEVW0hiB5KKP9gs_AkW8J4dOvbdPN
By using YouTube Data API, you can test the results:
URL: https://youtube.googleapis.com/youtube/v3/playlists?part=id%2Csnippet%2Cstatus&id=OLAK5uy_nvZSUlZB8qwifPgIVCoEulF4VyErdBX48&key=[YOUR_API_KEY]
Results:
{
"kind": "youtube#channelListResponse",
"etag": "Yw1yJOOwI7LJ8LeYmvQ8wpyHWbU",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "wDhMSGEntArTZuX56hjNjytDUlU",
"id": "UCFtEEv80fQVKkD4h1PF-Xqw",
"snippet": {
"title": "Microsoft",
"description": "Innovation is a key ingredient in Microsoft’s mission: to empower every person and organization on the planet to achieve more. \n\nSubscribe to Microsoft's official YouTube channel to explore technology’s role in making the world more sustainable, inclusive, and innovative for all.\n\n",
"customUrl": "microsoft",
"publishedAt": "2006-02-13T05:21:44Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AKedOLRZENZBPyEEG2cd0PZXemKKyG1GMGVJXmzHhrs4=s88-c-k-c0x00ffffff-no-rj",
"width": 88,
"height": 88
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AKedOLRZENZBPyEEG2cd0PZXemKKyG1GMGVJXmzHhrs4=s240-c-k-c0x00ffffff-no-rj",
"width": 240,
"height": 240
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AKedOLRZENZBPyEEG2cd0PZXemKKyG1GMGVJXmzHhrs4=s800-c-k-c0x00ffffff-no-rj",
"width": 800,
"height": 800
}
},
"localized": {
"title": "Microsoft",
"description": "Innovation is a key ingredient in Microsoft’s mission: to empower every person and organization on the planet to achieve more. \n\nSubscribe to Microsoft's official YouTube channel to explore technology’s role in making the world more sustainable, inclusive, and innovative for all.\n\n"
},
"country": "US"
},
"contentDetails": {
"relatedPlaylists": {
"likes": "",
"uploads": "UUFtEEv80fQVKkD4h1PF-Xqw"
}
},
"status": {
"privacyStatus": "public",
"isLinked": true,
"longUploadsStatus": "longUploadsUnspecified"
}
}
]
}
When you query a normal playlist (that belongs to the channel), you will get these results:
URL: https://youtube.googleapis.com/youtube/v3/playlists?part=id%2Csnippet%2Cstatus&id=PL3tRBEVW0hiB5KKP9gs_AkW8J4dOvbdPN&key=[YOUR_API_KEY]
Results:
{
"kind": "youtube#playlistListResponse",
"etag": "OV6gnfMDH09mU3YBdHPuf5uz1Jg",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#playlist",
"etag": "X8YVDKLXZZfHlVTh_ud0LD-IMMQ",
"id": "PL3tRBEVW0hiB5KKP9gs_AkW8J4dOvbdPN",
"snippet": {
"publishedAt": "2016-05-15T15:29:30Z",
"channelId": "UC7_YxT-KID8kRbqZo7MyscQ",
"title": "DOOM",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Markiplier",
"localized": {
"title": "DOOM",
"description": ""
}
},
"status": {
"privacyStatus": "public"
}
}
]
}
Check this answer for more details.

Spree API 3.7 : Images comes as separate object instead of embedded inside product itself

Spree API when hitting /products?include=images path gives the response in following format.
{
"data": [...],
"included": [
{
"id": "4",
"type": "image",
"attributes": {
"viewable_type": "Spree::Variant",
"viewable_id": 3,
"styles": [
{
"url": "/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBDUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--bd6df012d992b43227344ecb03dc0ab6e13b1555/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lMTkRoNE5EZytCam9HUlZRPSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--504f95c059f17243e0d7d1312e2b387f26a40aff/bg.jpg",
"width": "48",
"height": "48"
},
{
"url": "/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBDUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--bd6df012d992b43227344ecb03dc0ab6e13b1555/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lOTVRBd2VERXdNRDRHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--594f543b42e0bfafbe9d09df814e1d60837f9ef6/bg.jpg",
"width": "100",
"height": "100"
},
{
"url": "/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBDUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--bd6df012d992b43227344ecb03dc0ab6e13b1555/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lOTWpRd2VESTBNRDRHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--46583de60196cb1eee5b4a704d67209eee40c09a/bg.jpg",
"width": "240",
"height": "240"
},
{
"url": "/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBDUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--bd6df012d992b43227344ecb03dc0ab6e13b1555/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lOTmpBd2VEWXdNRDRHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--3b3e65d1d9c712d2d540e15aa84ca541eb12b365/bg.jpg",
"width": "600",
"height": "600"
}
]
}
}],
"meta": {
"count": 14,
"total_count": 14,
"total_pages": 1
},
"links": {
"self": "https://galific.herokuapp.com/api/v2/storefront/products?include=variants.images",
"next": "https://galific.herokuapp.com/api/v2/storefront/products?include=variants.images&page=1",
"prev": "https://galific.herokuapp.com/api/v2/storefront/products?include=variants.images&page=1",
"last": "https://galific.herokuapp.com/api/v2/storefront/products?include=variants.images&page=1",
"first": "https://galific.herokuapp.com/api/v2/storefront/products?include=variants.images&page=1"
}
}
}
Here you can see the image URL's are coming as included object. While developing for mobile its not a good idea to put the very crucial element (product image path in this case) in separate object. This require the mobile dev to loop unnecessary just to get the image path which can be provided within the image relationships object like this:
"images": {
"data": [
{
"id": "2",
"type": "image",
"url" : 'image-path.jpg'
}]
}
The image path should be included in data object itself rather than separated include object. Is there any way to do it without messing with source??

Facebook Graph API get photos returns with duplicated size.? Can I reduct the return?

How should I removed the duplicated size photos?
I just want one size for each photo.
But it returns images array and each array is one image with different sizes.
The service I'm calling is:
{user-id}/photos/uploaded?fields=images
returns:
"data": [
{
"images": [
{
"height": 960,
"source": "https://scontent.xx.fbcdn.net/hphotos-ash2/v/t1.0-9/10734238_10204858324278565_766379049543592577_n.jpg?oh=6ece9809697d2ca4019087d2173702d3&oe=56D2FB6C",
"width": 720
},
{
"height": 800,
"source": "https://fbcdn-photos-c-a.akamaihd.net/hphotos-ak-ash2/v/t1.0-0/p600x600/10734238_10204858324278565_766379049543592577_n.jpg?oh=8aabb9ba4538fdcf853b8c9107601f15&oe=56941F5E&__gda__=1455658621_d167345958233195768c68333d481f1a",
"width": 600
},
{
"height": 640,
"source": "https://fbcdn-photos-c-a.akamaihd.net/hphotos-ak-ash2/v/t1.0-0/p480x480/10734238_10204858324278565_766379049543592577_n.jpg?oh=2810aba0ea4eda0ee5ff73b5df75a70c&oe=56C3DF77&__gda__=1452026196_7d112ea2ad4fa41b108a883a27819241",
"width": 480
},

Get all playlist ids from channel id - youtube api v3

I am currently learning the use of the youtube api. I want to retrieve all playlists id from a channel id. I read through the documentation and saw that I can use youtube.channels.list for such task. I did basic testing on the api_page. Still, I am not able to figure what params to use to get the playlist id. How can I retrieve all playlist ids from a given channel id?
https://www.googleapis.com/youtube/v3/channels?part=id&id=UCF0pVplsI8R5kcAqgtoRqoA&key={YOUR_API_KEY}
A simple way :
With the YouTube API v3 with the ressource playlists.list
Use this parameters to get the playlists ID of a channel :
part: 'snippet'
channelId: 'UCBkNpeyvBO2TdPGVC_PsPUA'
https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCBkNpeyvBO2TdPGVC_PsPUA&key={YOUR_API_KEY}
The output :
"items": [
{
"kind": "youtube#playlist",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/K21sgPQuMRCjhSMBjm3v3n5tl1o\"",
"id": "PL2qcutlDmS0CnyV8Jcbl2d7yFxd2iGg67",
"snippet": {
"publishedAt": "2014-07-08T03:13:37.000Z",
"channelId": "UCBkNpeyvBO2TdPGVC_PsPUA",
"title": "These Things Happen Series",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "GEazyTV"
}
},
{
"kind": "youtube#playlist",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/5ifuvTYKbyV6DUPqbTa2bnO2jWY\"",
"id": "PL2qcutlDmS0B0jwHOQYzgRhJpnxDwPBHc",
"snippet": {
"publishedAt": "2014-06-05T07:36:58.000Z",
"channelId": "UCBkNpeyvBO2TdPGVC_PsPUA",
"title": "B-Sides",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "GEazyTV"
}
},
...
This is a sample example with a random channel.
If you don't know how to get the channelID of a channel use ressource channels.list:
With this parameters to get the video ID of a playlist :
part: 'id'
forUsername: 'channel_name'
https://www.googleapis.com/youtube/v3/channels?part=id&forUsername=GEazyTV&key={YOUR_API_KEY}
"items": [
{
"kind": "youtube#channel",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/vIwM6ev74Om0AOupX26jJoEDELU\"",
"id": "UCBkNpeyvBO2TdPGVC_PsPUA"
}
I'm not sure how I came across this solution, but I've found that if you follow these steps then you can retrieve the playlistID to use:
Create an API Key using the Google API Console.
Use
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&key=[KEY FROM GOOGLE API CONSOLE]&id=[CHANNEL ID]
where you are replacing everything, including the brackets, with the corresponding info (I find channel ids are easy to come by since they are normally in the URL. The PlaylistID is the one that tends to be difficult).
The resulting feed from the URL in step 2 should contain an uploads object, containing the playlistID which is used in the URL in step 4.
Use
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=[PLAYLIST ID RETRIEVED IN STEP 3 HERE]&key=[KEY FROM GOOGLE API CONSOLE]
The link from step 4 is what should end up being used in the app.
This works for me every time, and I integrate the YouTube v3 API in many apps. I completely agree with #Utkanos' comment that while #mpgn's answer works sometimes, it certainly doesn't work for all channels.
Youtube Api v3 Channel Playlist video max 50
This url format work
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=[]&key=[]&maxResults=50

How to add search term to Spotify API

I am building an app using rails, angular, and RSpotify. I'm still kind of a newbie, and feel like the answer to my question is right in front of me, but I am struggling to figure it out.
After I authenticate a user, I redirect to a search to find new songs/albums/artist etc. Once they find relevant songs, they can add them to a playlist.
Using RSpotify, I can make the data to json, and then show that data using angular. Here is an example of what I am doing;
users_controller.rb
def music
music = RSpotify::Artist.search("Wiz Khalifa")
respond_to do |format|
format.json { render :json => music}
end
end
I added to my routes, and now this spits out some data;
localhost:3000/api/music.json
[
{
"genres": [],
"images": [
{
"height": 1200,
"url": "https://i.scdn.co/image/6fcf0a3556f9edf47f4d17c33a48418a3d2e6bce",
"width": 900
},
{
"height": 853,
"url": "https://i.scdn.co/image/d803a20e1402bf2c46353c97d929a3f28c27366e",
"width": 640
},
{
"height": 267,
"url": "https://i.scdn.co/image/0d706a776e505ad54968f389e4c6b820a7615562",
"width": 200
},
{
"height": 85,
"url": "https://i.scdn.co/image/534b45d0038ca0142b50dcc3f338a8fdd9caa949",
"width": 64
}
],
"name": "Wiz Khalifa",
"popularity": 91,
"top_tracks": {},
"external_urls": {
"spotify": "https://open.spotify.com/artist/137W8MRPWKqSmrBGDBFSop"
},
"href": "https://api.spotify.com/v1/artists/137W8MRPWKqSmrBGDBFSop",
"id": "137W8MRPWKqSmrBGDBFSop",
"type": "artist",
"uri": "spotify:artist:137W8MRPWKqSmrBGDBFSop"
},
{
"genres": [],
"images": [
{
"height": 640,
"url": "https://i.scdn.co/image/d4e1be09af57961ff630662daa5e44e75a99f18b",
"width": 640
},
{
"height": 300,
"url": "https://i.scdn.co/image/814960e7e3b52dc4b9985974e4b9f4e25e40860c",
"width": 300
},
{
"height": 64,
"url": "https://i.scdn.co/image/aa9543dd6a6fba6be98894c02141943da40cb81d",
"width": 64
}
],
"name": "Snoop Dogg & Wiz Khalifa",
"popularity": 34,
"top_tracks": {},
"external_urls": {
"spotify": "https://open.spotify.com/artist/3rnsFvKusYivCTnK2fpwbu"
},
"href": "https://api.spotify.com/v1/artists/3rnsFvKusYivCTnK2fpwbu",
"id": "3rnsFvKusYivCTnK2fpwbu",
"type": "artist",
"uri": "spotify:artist:3rnsFvKusYivCTnK2fpwbu"
},
{
"genres": [],
"images": [
{
"height": 600,
"url": "https://i.scdn.co/image/425f29c04ce8953339cac3b47e56dce53a82d396",
"width": 600
},
{
"height": 300,
"url": "https://i.scdn.co/image/7ea62fef2465095d3283843defd4daefb1a9b627",
"width": 300
},
{
"height": 64,
"url": "https://i.scdn.co/image/7f92197321b425d83b63ad3db550729fec74df9b",
"width": 64
}
],
"name": "BAyBOy Ft. Wiz Khalifa",
"popularity": 0,
"top_tracks": {},
"external_urls": {
"spotify": "https://open.spotify.com/artist/15qZ54HBDz6nDQKvafOKqG"
},
"href": "https://api.spotify.com/v1/artists/15qZ54HBDz6nDQKvafOKqG",
"id": "15qZ54HBDz6nDQKvafOKqG",
"type": "artist",
"uri": "spotify:artist:15qZ54HBDz6nDQKvafOKqG"
},
So, I am able to reach the data from spotify which is good. However, the call Artist.search takes a parameter. So my question is, using a search tab like this;
home.html.erb
<%= form_tag "/music" do %>
<%= label_tag :search %>
<%= text_field_tag :search %>
<%= submit_tag :search %>
<% end %>
How could I add user input from the search bar as the parameter for RSpotify::Artist.search()? Any help pointing me in the right direction is very appreciated. Thanks.
users_controller.rb
def music
#music = RSpotify::Artist.search(params[:search])
render :json => #music
end

Resources