I've looked into how to play 30 second previews but so far all I can find is android wrappers for the web API that require user authentication.
I need to be able to search for an artist and play the first preview that pops up without needing the user to authenticate their accounts
You should check: https://developer.spotify.com/web-api/code-examples/
"Search for an Artist (and Lookup) Demo"
It's an example for a web snippet, but you could try to see how it does the connection without needing the user authentication.
If you look at spotify api webpage they mention Endpoints marked “OAuth” above require application registration and user authorization via the Spotify Accounts Service to access certain data.
So in order to get this working i had to chain 2 API calls together. The first one searches for the artist and then the second one looks for the preview:
You call the API with this link (GET):
https://api.spotify.com/v1/search?q=<artist name>&type=artist
which then returns a json structure like this:
{
"artists": {
"href": "https://api.spotify.com/v1/search?query=bring+me+the+horizon&offset=0&limit=20&type=artist",
"items": [
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/1Ffb6ejR6Fe5IamqA5oRUF"
},
"followers": {
"href": null,
"total": 1067846
},
"genres": [
"metalcore"
],
"href": "https://api.spotify.com/v1/artists/1Ffb6ejR6Fe5IamqA5oRUF",
"id": "1Ffb6ejR6Fe5IamqA5oRUF",
"images": [
{
"height": 640,
"url": "https://i.scdn.co/image/49aad7da4f872acb3005727392631dab282423d1",
"width": 640
},
{
"height": 320,
"url": "https://i.scdn.co/image/d9cf89b9db73b95ed15d9e29e30d0dd8afea23e2",
"width": 320
},
{
"height": 160,
"url": "https://i.scdn.co/image/d9e514e15f4940c77029ef3b11291d557b345ae9",
"width": 160
}
],
"name": "Bring Me The Horizon",
"popularity": 76,
"type": "artist",
"uri": "spotify:artist:1Ffb6ejR6Fe5IamqA5oRUF"
}
],
"limit": 20,
"next": null,
"offset": 0,
"previous": null,
"total": 1
}
}
Because this then returns the Artist ID we can get the top tracks for that artist and play a preview:
Call the API with this URL (GET):
https://api.spotify.com/v1/artists/<ARTIST ID>/top-tracks?country=GB
From here we can then extract the URL of the preview and play it, all without authentication!
Related
We are running MobileFirst Consumer Edition 7.0 We have a Liberty Server.
A majority of our users are able to successfully authenticate using our Mobile App with a AD Login.
A few users have reported that the log in hangs. Some other relevant information: the users who have experienced this issue are using Android 5.0.2. I can log in as them on other versions of Android without any problem. (I personally haven't been able to duplicate this). When they log in, I am seeing this error in the logs when the login hangs. What could be the issue? If you need additional logs or a copy of the code, I can supply that via email. I just do not wish to disclose full logs here.
{
"message": "Session ended for user \u0027REMOVED\u0027",
"level": "INFO",
"source": "server",
"threadId": 52,
"loggerName": "com.worklight.core.util.AuditBean",
"timestamp": "25-08-15 10:50:45:320"
},
{
"message": "Session ended for user \u0027REMOVED\u0027",
"level": "INFO",
"source": "server",
"threadId": 52,
"loggerName": "com.worklight.core.util.AuditBean",
"timestamp": "25-08-15 10:42:27:321"
},
{
"message": "FWLSE0048E: Unhandled exception caught: java.util.NoSuchElementException\ncom.worklight.gadgets.GadgetRuntimeException: java.util.NoSuchElementException\n\tat com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfoStandard(GadgetAPIRequestCoder.java:408)\n\tat com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfo(GadgetAPIRequestCoder.java:236)\n\tat com.worklight.gadgets.utils.GadgetUtils.getApplicationEnvironmentFrom(GadgetUtils.java:225)\n\tat com.worklight.core.auth.impl.AuthenticationFilter.isDeviceDisabled(AuthenticationFilter.java:535)\n\tat com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:186)\n\tat com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:86)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:975)\n\tat com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1097)\n\tat com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)\n\tat com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:912)\n\tat com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)\n\tat com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:938)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\n\tat java.lang.Thread.run(Thread.java:722)\nCaused by: java.util.NoSuchElementException\n\tat java.util.StringTokenizer.nextToken(StringTokenizer.java:349)\n\tat com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfoStandard(GadgetAPIRequestCoder.java:367)\n\t... 15 more\n [project MyGPCMobile]",
"sourceClass": "com.worklight.core.auth.impl.AuthenticationFilter",
"sourceMethodName": "doFilter",
"throwable": {
"message": "java.util.NoSuchElementException",
"stacktrace": [
"com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfoStandard(GadgetAPIRequestCoder.java:408)",
"com.worklight.gadgets.api.GadgetAPIRequestCoder.decodeGadgetRequestInfo(GadgetAPIRequestCoder.java:236)",
"com.worklight.gadgets.utils.GadgetUtils.getApplicationEnvironmentFrom(GadgetUtils.java:225)",
"com.worklight.core.auth.impl.AuthenticationFilter.isDeviceDisabled(AuthenticationFilter.java:535)",
"com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:186)",
"com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)",
"com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:86)",
"com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:975)",
"com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1097)",
"com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)",
"com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:912)",
"com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)",
"com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:938)",
"java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)",
"java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)",
"java.lang.Thread.run(Thread.java:722)"
]
},
"level": "SEVERE",
"source": "server",
"threadId": 196547,
"loggerName": "com.worklight.core.auth.impl.AuthenticationFilter",
"timestamp": "25-08-15 10:40:07:590"
},
{
"message": "Session started for user \u0027REMOVED\u0027",
"level": "INFO",
"source": "server",
"threadId": 191685,
"loggerName": "com.worklight.core.util.AuditBean",
"timestamp": "25-08-15 10:39:43:905"
},
{
How to read heart rate data from polar h7 heart rate monitor device? I'm using evothings phonegap plugin for android. I am able to read service data which include a list of characteristics, handle values. But how to read heart rate value?
// ..
{
"type": 0,
"uuid": "0000180d-0000-1000-8000-00805f9b34fb",
"handle": 3,
"characteristics": [
{
"permissions": 0,
"writeType": 2,
"properties": 16,
"uuid": "00002a37-0000-1000-8000-00805f9b34fb",
"handle": 13,
"descriptors": [
{
"permissions": 0,
"uuid": "00002902-0000-1000-8000-00805f9b34fb",
"handle": 24
}
]
},
{
"permissions": 0,
"writeType": 2,
"properties": 2,
"uuid": "00002a38-0000-1000-8000-00805f9b34fb",
"handle": 14,
"descriptors": [
]
}
]
}, // ...
Calling evothings.ble.enableNotification(1, 13, ..) is giving null.
Looks like the Polar H7 follows the Heart Rate Profile specification. Of interest is the heart_rate_measurement characteristic, which has UUID 2a37 and can be seen in your list.
Calling evothings.ble.enableNotification is only half of what you need to do. You must also call evothings.ble.writeDescriptor(1, 24, new Uint8Array([1,0]), ...) to actually start the notification.
If notification fails, you can use readDescriptor() to poll.
i am doing a bar code scanner application.I am trying to get Google book details from the bar code ISBN number in android application. Also i got all the book details from API result successfully. But if i try to access the buy link from API result, i am unable to access the buy link of the book. It says 404 error. Can anyone help me, how to access the buy link to buy a book.? Thanks in advance.
Here is the buy link of book got from below result:
http://books.google.co.in/books?id=xqxBtXmxqV4C&dq=isbn:9781849699327&hl=&buy=&source=gbs_api
Here is the API result:
"saleInfo": {
"country": "IN",
"saleability": "FOR_SALE",
"isEbook": true,
"listPrice": {
"amount": 162.0,
"currencyCode": "INR"
},
"retailPrice": {
"amount": 113.4,
"currencyCode": "INR"
},
"buyLink": "http://books.google.co.in/books?id=xqxBtXmxqV4C&dq=isbn:9781849699327&hl=&buy=&source=gbs_api",
"offers": [
{
"finskyOfferType": 1,
"listPrice": {
"amountInMicros": 1.62E8,
"currencyCode": "INR"
},
"retailPrice": {
"amountInMicros": 1.134E8,
"currencyCode": "INR"
}
}
]
I would like to integrate Facebook's comment social plugin
( https://developers.facebook.com/docs/reference/plugins/comments/ to comment on url) into my android application.
I tried to use webview (use this answer Android unable to implement facebook comment in a webview due to default browser ) and it's work, but hard to customize, for example: I want to have a bigger Textbox for user to type the comment. My question is: "is there any solution to integrate something like "Facebook's comment social plugin" into android application by facebook sdk, java code,... to comment on url?
Thanks & best regards
As far as I understand you have some URL page where you've embedded your facebook social plugin with comments and you want to parse this and display as you want. If I'm right, then unfortunately I haven't found easy solution via triggering appropriated methods from Facebook SDK. You have to use Graph API.
First of all we need to take a look into docs - https://developers.facebook.com/docs/graph-api/reference/v2.3/object/comments
Here there is a example of call
/* make the API call */
new Request(
session,
"/{object-id}/comments",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
For getting {object_id} you need to send similar call to the Graph API, but for retrieving id:
GET-> ?id=http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt2015381%2F
And you will receive response which looks like
{
"og_object": {
"id": "10150298925420108",
"description": "Directed by James Gunn. With Chris Pratt, Vin Diesel, Bradley Cooper, Zoe Saldana. A group of intergalactic criminals are forced to work together to stop a fanatical warrior from taking control of the universe.",
"title": "Guardians of the Galaxy (2014)",
"type": "video.movie",
"updated_time": "2015-05-15T14:52:46+0000",
"url": "http://www.imdb.com/title/tt2015381/"
},
"share": {
"comment_count": 4,
"share_count": 91073
},
"id": "http://www.imdb.com/title/tt2015381/"
}
10150298925420108 is our object_id
So next query looks like GET -> 10150298925420108/comments
and response
{
"data": [
{
"id": "10150298925420108_10152457293990108",
"can_remove": false,
"created_time": "2014-10-28T18:12:15+0000",
"from": {
"id": "1513986108857171",
"name": "ซอโซ่ สระอา ยอยัก"
},
"like_count": 2,
"message": "สนุกมากค่ะ",
"user_likes": false
},
{
"id": "10150298925420108_10152457392770108",
"can_remove": false,
"created_time": "2014-10-28T19:20:28+0000",
"from": {
"id": "302917246580502",
"name": "สมชาย โกทันธ์"
},
"like_count": 0,
"message": "สองดาวครับ\n",
"user_likes": false
},
{
"id": "10150298925420108_10152461977130108",
"can_remove": false,
"created_time": "2014-10-31T11:57:10+0000",
"from": {
"id": "472810482857795",
"name": "Surat Thaenphet"
},
"like_count": 0,
"message": "แต่ละเรื่องที่ลง สนุกมาก แต่ดูไม่จบ ดูสักพัก ก็ eror ไม่รุ้เป็นเพราะอะไร",
"user_likes": false
}
],
"paging": {
"cursors": {
"before": "Mw==",
"after": "MQ=="
}
}
}
To test all this requests and response before doing it in Android app - use Graph API explorer https://developers.facebook.com/tools/explorer/
I am developing an android App and want to incorporate Facebook in it. I have an App ID and the Facebook Library is added to my project. I want to retrieve the post from my NewsFeed that says that a friend of mine has uploaded new pictures. I can see that post in my NewsFeed both on my mobile Facebook app and on web at my PC but when i try to recover a string using following relevant code:
private static final String[] PERMS = new String[] {"user_events", "friends_events", "user_photos", "friends_photos", "friends_activities", "friends_videos",
"email", "publish_stream", "read_stream"};
private Facebook mFacebook;
private AsyncFacebookRunner mAsyncRunner;
.........
mFacebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
.........
mFacebook.authorize(this, PERMS, new DialogListener()
{
.........
}
.........
{
mAsyncRunner.request("me/home", new UserNewsFeedListener(), "newsfeedForPhotos");
}
I then print the resulting response string in UserNewsFeedListener()'s onComplete() method. I get all the posts that I made on my wall and the posts my friend made on my wall that were appearing in newsfeed but the post showing pictures uploaded by my friend is not showing up in the resulting response string.
I also tried using FQL but i got the same result. Please help. Am I doing something wrong? Can I get this post information and then use it to get those pictures of my friend?
Any help will be appreciated. Thanks.
you are doing the right thing and the photo posts should show up. I just tested it on my sample app with the me/home graph path and it correctly shows the photos that my friends uploaded:
{
"id": "100001742041368_187606011307466",
"from": {
"name": "Vikas Fbone",
"id": "100001742041368"
},
"picture": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300204_187605997974134_100001742041368_424627_3637528_s.jpg",
"link": "https://www.facebook.com/photo.php?fbid=187605997974134&set=a.121410007927067.19689.100001742041368&type=1",
"name": "Wall Photos",
"icon": "https://s-static.ak.facebook.com/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/100001742041368/posts/187606011307466"
},
{
"name": "Like",
"link": "https://www.facebook.com/100001742041368/posts/187606011307466"
}
],
"type": "photo",
"object_id": "187605997974134",
"created_time": "2011-08-29T20:58:24+0000",
"updated_time": "2011-08-29T20:58:24+0000",
"comments": {
"count": 0
}
},
{
"id": "100001742041368_187605864640814",
"from": {
"name": "Vikas Fbone",
"id": "100001742041368"
},
"picture": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/311649_187605844640816_100001742041368_424626_663667_s.jpg",
"link": "https://www.facebook.com/photo.php?fbid=187605844640816&set=a.121410007927067.19689.100001742041368&type=1",
"name": "Wall Photos",
"icon": "https://s-static.ak.facebook.com/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/100001742041368/posts/187605864640814"
},
{
"name": "Like",
"link": "https://www.facebook.com/100001742041368/posts/187605864640814"
}
],
"type": "photo",
"object_id": "187605844640816",
"created_time": "2011-08-29T20:58:07+0000",
"updated_time": "2011-08-29T20:58:07+0000",
"comments": {
"count": 0
}
},
Do you see other posts from your same friend? If not, he may have blocked access to Facebook platform and any of his posts won't show up. The platform can be enabled by visiting Account->Privacy Settings->Edit your Settings (under Apps and Websites at the bottom right)->Apps you see - Turn on all platform.