Echonest track profile requests always return an empty audio_summary - echonest

I'm requesting bucket=audio_summary for songs that rank highly in hotttness.
The top 100 hotttessst songs all return track.status: 'complete' but the audio summary is always an empty object.
How do I get audio summary data like time_signature and tempo? Doesn't track.status: complete imply that this information should be included in the response?
Can't Feel My Face
https://developer.echonest.com/api/v4/track/profile?api_key=*****************&format=json&id=SOMVZDS14DDE5909E7&bucket=audio_summary
{
"response": {
"status": {
"version": "4.2",
"code": 0,
"message": "Success"
},
"track": {
"status": "complete",
"id": "SOZOIDR14C02B654D4",
"audio_summary": {}
}
}
}

It looks like you have the SongId rather than the TrackId for this song. If you replace 'track' with 'song' in your query you get the expected results.
This:
https://developer.echonest.com/api/v4/song/profile?api_key=*****************&format=json&id=SOMVZDS14DDE5909E7&bucket=audio_summary
Returns this:
{
"response":{
"status":{
"version":"4.2",
"code":0,
"message":"Success"
},
"songs":[
{
"artist_id":"ARYUDWF12F2B89BB33",
"artist_name":"The Weeknd",
"id":"SOMVZDS14DDE5909E7",
"audio_summary":{
"key":9,
"analysis_url":"http://echonest-analysis.s3.amazonaws.com/TR/A7NwGAWSmhnc53M8w1rLk-eA_tsN8OUHaqV5C5FTbb9BnCPZVnxWOGld1wLxJJ-xdNV8xKJbbZlCRSKJc%3D/3/full.json?AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1454028841&Signature=HeUxbEJt4f0ncipjD1Gamtuj08E%3D",
"energy":0.781735,
"liveness":0.12022,
"tempo":107.954,
"speechiness":0.042317,
"acousticness":0.124391,
"instrumentalness":0.0,
"mode":0,
"time_signature":4,
"duration":216.46667,
"loudness":-5.528,
"audio_md5":"",
"valence":0.586261,
"danceability":0.713659
},
"title":"Can't Feel My Face"
}
]
}
}
The only reason I was able to track this down was that throwing any ID into the track API give back the stub response you were seeing and I was able to get the audio_summary for this song using the spotify id so I knew it was available.

Related

Retrieve Facebook reviews likes via Graph API

I am trying to retrieve some reviews data from Graph API, including comments, sub-comments, etc.
I can get like_count on comments using the endpoint with these parameters:
{page-id}/ratings?fields=open_graph_story{comments{like_count}}
Or the same thing with sub-comments:
{page-id}/ratings?fields=open_graph_story{comments{comments{like_count}}}
But I can't seem to find how to get them for the review itself.
I tried this:
{page-id}/ratings?fields=open_graph_story,like_count
And this (which throws an error):
{page-id}/ratings?fields=open_graph_story{like_count}
Just to be clear: in this question I separated the calls for likes on comments/sub-comments, but in reality, I'm getting all the data in a single call like this:
{page-id}/ratings?access_token={access-token}&fields=open_graph_story{comments{created_time,from,message,comments{created_time,from,message,like_count,user_likes},like_count,user_likes}},rating,review_text,created_time,reviewer
try
graph.facebook.com/open_graph_story_id?fields=likes
should return a payload structured similar to below
{
"likes": {
"data": [
],
"can_like": true,
"count": 0,
"user_likes": false
},
"id": "open_graph_story_id"
}

Can't post node that requires a pre assigned value with services api

I have setup a content type with a subject field that has pre assigned values in a dropdown field.
I am using the services api to post new content from a polymer app.
When I POST to the api I send the field structure and value in json but get and error.
"406 (Not Acceptable : An illegal choice has been detected. Please contact the site administrator.)"
Even though the object I am sending matches one of the required values in the field.
Do I need to prefix the value with something? I assume I'm posting to the right place to get that response but don't know why it would accept anything other than the string value.
Here is what I sent to the api which is picked up by my Charles proxy.
{
"node": {
"type": "case",
"title": "my case",
"language": "und",
"field_subject": {
"und": {
"0": {
"value": "subject1"
}
}
},
"body": {
"und": {
"0": {
"value": "my details of subject"
}
}
}
}
}
And here is an example of what I have setup in my Drupal field
subject1| first
subject2| second
subject3| third
subject4| forth
For anyone else with the same problem, this subject is poorly documented, but the answer is simple, my subject did not need the value key despite devel suggesting thats how it would be formatted.
"field_subject": {
"und": [
"subject1"
]
}
I could also shorten my code with "und" being an array.

How should we retrieve an individual post now that /[post-id] is deprecated in v2.4?

I just tried through the Graph API Explorer with this path /v2.4/10153513872748291 and I've got this result:
{
"error": {
"message": "(#12) singular links API is deprecated for versions v2.4 and higher",
"type": "OAuthException",
"code": 12
}
}
But https://developers.facebook.com/docs/reference/api/post/ doesn't say anything about deprecation.
I'm not sure if I miss something, or there's another way to get info about an individual post.
Edit: v2.3 works, but v2.4 is the latest one.
Looks like you now need to the combination of the id of the user or page that made the post (or whose wall it is on), an underscore, and then the post id.
For your example post, 10153513872748291, that is made by a page Drama-addict, that has the id 141108613290 – so 141108613290_10153513872748291 will work.
And so does 788239567865981_10153513872748291, because 788239567865981 is the id of the user making the post.
Firstput userId underscore add postId /Likes to check Like status in facebook
userId_post_Id/Likes to fetch Likes Records
userId_post_Id/Comments to fetch Comments Records
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=303261006522998_751199848395776%2FLikes&version=v2.9
**In this link Right side Get Token indide GetAccessToken to select Permission**
303261006522998_751199848395776/Likes
303261006522998_751199848395776/Comments
{
"data": [
{
"id": "124778301449917",
"name": "Manisha Gera"
},
{
"id": "1680577265523548",
"name": "Rubi Sharma"
}
],
"paging": {
"cursors": {
"before": "MTI0Nzc4MzAxNDQ5OTE3",
"after": "MTY4MDU3NzI2NTUyMzU0OAZDZD"
}
}
}

Pagination issue in RESTful API design

I am designing a RESTful API for a mobile application I am working on. My problem is with large collections containing many items. I understand that a good practice is to paginate large number of results in a collection.
I have read the Facebook Graph API doc (https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2), Twitter cursors doc (https://dev.twitter.com/overview/api/cursoring), GitHub API doc (https://developer.github.com/v3/) and this post (API pagination best practices).
Consider an example collection /resources in my API that contains 100 items named resource1 to resource100 and sorted descending. This is the response you will get upon a GET request (GET http://api.path.com/resources?limit=5):
{
"_links": {
"self": { "href": "/resources?limit=5&page=1" },
"last": { "href": "/resources?limit=5&page=7" },
"next": { "href": "/resources?limit=5&page=2" }
},
"_embedded": {
"records": [
{ resource 100 },
{ resource 99 },
{ resource 98 },
{ resource 97 },
{ resource 96 }
]
}
}
Now my problem is a scenario like this:
1- I GET /resources with above contents.
2- After that, something is added to the resources collection (say another device adds a new resource for this account). So now I have 101 resources.
3- I GET /resources?limit=5&page=2 as the initial response suggests will contain the next page of my results. The response would be like this:
{
"_links": {
"self": { "href": "/history?page=2&limit=5" },
"last": { "href": "/history?page=7&limit=5" },
"next": { "href": "/history?page=3&limit=5" }
},
"_embedded": {
"records": [
{ resource 96 },
{ resource 95 },
{ resource 94 },
{ resource 93 },
{ resource 92 }
]
}
}
As you can see resource 96 is repeated in both pages (Or similar problem may happen if a resource gets deleted in step 2, in that case one resource will be lost).
Since I want to use this in a mobile app and in one list, I have to append the resources of each API call to the one before it so I can have a complete list. But this is troubling. Please let me know if you have a suggestion. Thank you in advance.
P.S: I have considered timestamp like query strings instead of cursor based pagination, but that will make problems somewhere else for me. (let me know if you need more info about that.)
We just implemented something similar to this for a mobile app via a REST API. The mobile app passed an additional query parameter which represents a timestamp at which elements in the page should be "frozen".
So your first request would look something like GET /resources?limit=5&page=1&from=2015-01-25T05:10:31.000Z and then the second page request (some time later) would increment the page count but keep the same timestamp: GET /resources?limit=5&page=2&from=2015-01-25T05:10:31.000Z
This also gives the mobile app control if it wants to differentiate a "soft" page (preserving the timestamp of the request of page 1) from a "hard refresh" page (resetting the timestamp to the current time).
Why not just maintain a set of seen resources?
Then when you process each response you can check whether the resource is already being presented.

Facebook Credits Invalid State Transition Error

I am using Github sample code for the Facebook Credits (callback.php and index.php) but its giving me the below error.. anybody have any solution???
"Order::update_order called with invalid state transition:3 -> 0"
Thanks..
Hard to answer without seeing the code you're using, but the response you send should look like this:
{
"method": "payments_status_update",
"content": {
"order_id": ORDER_ID,
"status": "settled"
}
}
ORDER_ID should be replaced by the order id sent from fB with the request.
There were incorrect examples out there that showed:
{
"method": "payments_status_update",
"content": [{
"order_id": ORDER_ID,
"status": "settled"
}]
}
but the second one doesn't work. Check to make sure you're not sending content as an array.