Discover SoundCloud user name - soundcloud

I have a SoundCloud client_id that I would like to know the user_id or user name. Actually I have a full link to a track. Is there anyway I can do it?

I think what you're asking is with a track link, find the user_id and username of the uploader of a track.
If you know the full soundcloud.com track URL, hit the /resolve endpoint. For reference, I will be using this URL: https://soundcloud.com/madanofficial/the-police-walking-on-the-moon-j-art-madan-remix
HTTP GET: https://api.soundcloud.com/resolve.json?url=https%3A%2F%2Fsoundcloud.com%2Fmadanofficial%2Fthe-police-walking-on-the-moon-j-art-madan-remix&client_id=[YOUR client_id]
The resulting JSON:
{
"status": "302 - Found",
"location": "https://api.soundcloud.com/tracks/147986343.json?client_id=[YOUR client_id]"
}
When we hit the SoundCloud API again with the /tracks endpoint, just parse the user object that is returned.
"user": {
"id": 44553705,
"kind": "user",
"permalink": "madanofficial",
"username": "Madan.",
"uri": "https://api.soundcloud.com/users/44553705",
"permalink_url": "http://soundcloud.com/madanofficial",
"avatar_url": "https://i1.sndcdn.com/avatars-000098677604-mwg7te-large.jpg?e76cf77"
}

Related

Facebook Graph API does not return full post data

I'm using the Facebook Graph API to fetch a public page feed. I created a basic application to get appId and secret. When I make a call to PUBLIC_PAGE_ID/feed I can retrieve the correct list of posts in JSON, but they are missing all the field I need, described in docs, and only have message, created_time and id:
{
"data": [
{
"message": "...",
"created_time": "2015-06-11T07:57:05+0000",
"id": "23X12XXXXXX9836_11XXXXXXXX610XXXX52"
},
...
Why all other data isn't there?
The response to your query: /id/feed is the default response. To access more data, you have to pass a fields parameter with the keyword of data you would like to retrieve.
For example: <id>/feed?fields=id,message,picture,shares
This will return:
{
"data": [
{
"id": "1234567890",
"message": "Message",
"picture": "http://fbcdn.com/xxxxxx.jpg",
"shares": {
"count": 0
}
}
}
What I could figure out is you should submit the app for review with at least one permission what your app still needs and then you will get back every data what you ask in the fields parameter.

Facebook Graph API apprequests node doesn't return "from"

Moving from FQL to Graph API, I found that the V2.2 Graph API apprequests node returns inconsistent responses.
https://graph.facebook.com/v2.2/<id>/apprequests
sometimes returns JSON with the "from" field and sometimes not.
The correct JSON is:
"application": {
"name": "Myapp",
"namespace": "My NS",
"id": "123456"
},
"created_time": "2015-03-16T19:34:00+0000",
"data": "invite",
"from": {
"id": "111111",
"name": "Sender name"
},
"message": "Come and play!",
"to": {
"id": "99999",
"name": "Recipient"
},
"id": "123_456"
}
However, the "from" field in the JSON is sometimes missing (even when requesting it specifically in the "fields" parameter).
When using FQL, I always get the sender_uid field (with the same app token and same user):
SELECT request_id, app_id, recipient_uid, sender_uid FROM apprequest
WHERE app_id = <appID> and recipient_uid=<FBID>
Can anybody explain the mystery?
Facebook's response after investigating this bug: This is by design. There are certain privacy restrictions on Graph API which didn't apply to the deprecated FQL.
We investigated this on our end and found that this happens when the user blocked the application or completely removed Facebook's third party integration.

how to get facebook post after a graph search?

https://graph.facebook.com/search?access_token=xxxxxx&q=hello&type=post&fields=from,message,picture,link,name,caption,description,created_time&limit=1&locale=en_US&scope=publish_stream,offline_access,user_status,read_stream
After such a graph search, I get some data like:
{
"data": [
{
"from": {
"name": "Eric Fluegge",
"id": "100000626293694"
},
"message": "Well, here's go nothing. Hello Tennessee.",
"created_time": "2013-03-30T19:23:44+0000",
"id": "100000626293694_567340783296793"
}
],
"paging": {
"previous": "https://graph.facebook.com/search?fields=from,message,picture,link,name,caption,description,created_time&q=hello&limit=1&type=post&locale=en_US&access_token=XXXXXXXXXXXXX&since=1364671424&__previous=1",
"next": "https://graph.facebook.com/search?fields=from,message,picture,link,name,caption,description,created_time&q=hello&limit=1&type=post&locale=en_US&access_token=XXXXXXXXXXXXX&until=1364671423"
}
}
so, is "id": "100000626293694_567340783296793" a post id? If so, how to use this post id, query again, get only this certain post information? I would like to store post id to mysql table, then I want to query the post anytime in the future, thanks.
EIDT: in app setting, i have set the publish_stream,offline_access,user_status,read_stream
EIDT2:
I have tried into Graph API Explorer, choose read_stream and generate a long live token.
SELECT post_id, actor_id, message, type, attachment FROM stream WHERE post_id = "100000626293694_567340783296793"
the result still empty. so I cannot get a post bcause i am not a friend of the post auther? or 100000626293694_567340783296793 is not a post id? or other reason?
Yep, the "id": "100000626293694_567340783296793" is a post ID, you can query its data again with the following URL: http://graph.facebook.com/100000626293694_567340783296793
Attention!
You should ask for the read_stream permission/scope too! Or else you'll get the following error:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
And of course, append the access_token to your GET url. (and don't forget https too)
You can check the Graph API Reference here: Post - Facebook Developer Reference

How to get the id of the user that send the request?

In my app there is a MultiFriendSelector to invite friends.
I want that the recipient see in the canvas page the id of the user that has sent the request via MultiFriendSelector.
I need to get the id without using PHP or other server side language, but I can use javascript or fbml for example.
I believe Multifriend selector is a user-user request and a typical request looks the below (from attribute will tell you the request senders information)
{
"id": "REQUEST_OBJECT_ID",
"application": {
"name": "APP_DISPLAY_NAME",
"canvas_name": "APP_NAME", // This is identical to the app namespace
"namespace": "APP_NAMESPACE",
"id": "APP_ID"
},
"from": {
"name": "SENDER_USER_NAME",
"id": "SEND_USER_ID"
},
"message": "Check out this Awesome Request!",
"created_time": "2012-01-24T00:43:22+0000",
"type": "apprequest"
}

How to visuzlize facebook post

I have a post id (obtained from the Graph API), can I generate a URL which will display this post in Facebook's interface?
Seems there should be something like http://facebook.com/viewpost?postid=6666666666 ...
You want to manually construct a permalink given only the post ID?
The Graph API for a post ID returns the URLs the user should go to to comment on or like the post, assuming the viewing user has permission to do so.
Example:
GET http://graph.facebook.com/19292868552_10150189643478553?access_token={access token here}
Snipped some of the fields of the response, but you're looking for 'actions':
{
"id": "19292868552_10150189643478553",
"from": {
"name": "Facebook Platform",
"category": "Product/service",
"id": "19292868552"
},
// removed fields from response
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/19292868552/posts/10150189643478553"
},
{
"name": "Like",
"link": "https://www.facebook.com/19292868552/posts/10150189643478553"
},
{
"name": "Share",
"link": "http://networkedblogs.com/hGWk3?a=share"
}
],
// Snipped rest of response
In general, the format of a permalink seems to be:
https://www.facebook.com/{source id}/posts/{post object id}
(Source ID being the user or page ID where the post is)
You can't definitely reply on that URL format always being the same; the API response should be always accurate though