Given a link such as: https://soundcloud.com/glennon-williams/spacedude
What's the easiest way to get the user's id? Right now I parse the user's name so I get: glennon-williams
I then run a query on this name: http://api.soundcloud.com/users?q=glennon-williams&client_id=XXX and match the permalink to the user name I searched.
Is there a more straightforward / easier way to do this? What could go wrong with my approach?
I'd use the resolve endpoint.
https://developers.soundcloud.com/docs/api/reference#resolve
Here is the logic in JS:
SC.get('/resolve', { url: scurl }, function(resolverr) {
console.log(resolverr);
if(resolverr.kind == 'track')
{console.log(resolverr.user.id)}
else
{console.log(resolverr.id)}
});
http://jsfiddle.net/iambnz/6thxporm/
Without programming:
http://os.bnz-power.com/soursound/#/user/glennon-williams
Related
How can I get info about specific user or specific repo using github GraphQL? I've try this query:
{
search (query: "torvalds", type: USER, first: 1){
edges {
node {
}
}
}
}
but autocomplete for node show only __typename which return string "User".
DEMO
search returns a SearchResultItem, which is an interface. In order to access fields on it, you need to use a fragment on a concrete type like so:
{
search (query: "torvalds", type: USER, first: 1){
edges {
node {
... on User {
login
}
}
}
}
}
I made a short video tour of GitHub's GraphQL API which you might find useful: https://youtu.be/6xO87LlijoQ
EDIT: If you're just looking for a user or org and know the exact name, #stubailo's answer is actually better. You'll still need to use a fragment for most fields, but you'll get just one result of type RepositoryOwner.
The best way to get information about a specific user is to use the repositoryOwner query, like so:
{
repositoryOwner(login: "stubailo") {
login
... on User {
bio
}
}
}
Search is good too, but if you know the name of a user or organization, it's more direct to use the query above.
For over a week I'm trying to get the share count for a specific user post (that post has been directly shared by a friend).
All permissions are ok (read_stream included).
I've tried using the Graph API or via the FQL, all I can get is the comment count and the like count (share count doesn't even appear in the json response).
Is there something new to take into account to obtain that information?
Any help would be really appreciated.
Thanks in advance.
I am assuming you must be having the post id. So you can simply use the API-
/{post-id}?fields=shares
you'll get the response as-
{
"shares": {
"count": 999
},
"id": "POST_ID",
"created_time": "XXXX-XX-XX"
}
Demo
use ajax call to obtain the result
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
function setcount(id,urlForLike){
$.ajax({
url: urlForLike,
success: function(data){
// console.log(data[0].like_count);
$("#img-"+id).append(data[0].like_count);
}
});
}
then call the function from where you want the result
<script>
setcount("<?php echo 'SOMETHING UNIQUE';?>","<?php echo 'https://api.facebook.com/method/links.getStats?urls='YOUR URL");
</script>
then place this code to display the share count
<span id="img-<?php echo 'SOMETHING UNIQUE'; ?>">
wherever there is 'SOMETHING UNIQUE' change this to id of the post or number to append the data to the div/span. ALso change 'YOUR URL' to the url of the page/link whichever suits your need.
[{"url":"URL","normalized_url":"URL","share_count":4,"like_count":197,"comment_count":15,"total_count":216,"click_count":0,"comments_fbid":null,"commentsbox_count":0}]
above json data is how the output of the ajax call
I am trying to use facebook api to get my friends' relationship status:
FB.api("/me/friends", {
fields: "id, name, relationship_status, significant_other, picture.type(large)"
}, function (response) {
if (response.data) {
...
$.each(response.data, function (index, data) {
if (data.significant_other) {
// If has a significant other
} else {
// If do not have a significant other
}
});
}
});
I tried to determine if a friend has a significant other by looking at the significant_other field. But how can I know if my friend has a significant other but doesn't want to disclose?
I have a solution. If relationship_status equals "In a relationship" but data.significant_other is not in the data. Then that means the friend has a significant_other but does not want to disclose.
If data isn't accessible via the API, there's no way to access that data via the API
This is pretty much a tautology, but if the data were accessible to you, you'd have it via the API call you just included in your question
I am new in unity and trying to integrate Facebook unity SDK. But i am not able to find current logged-in user name. It will return only userId and accessToken. How to get login name after FB.Login("email")
After you login, you can get the name with:
FB.API("me?fields=name", Facebook.HttpMethod.GET, <your callback here>);
After calling the API
FB.API("me?fields=name", Facebook.HttpMethod.GET, NameCallBack);
get the exact name from the JSON like this:
void NameCallBack(FBResult result)
{
IDictionary dict = Facebook.MiniJSON.Json.Deserialize(result.Text) as IDictionary;
string fbname = dict["name"].ToString();
}
My best guess if I was to look somewhere is to make use of that userId and FQL to query Facebook for the name of the user.
For instance using the Graph API Explorer:
https://developers.facebook.com/tools/explorer
I used the following query:
Select name from user where uid = [userId]
It returned the following JSON string:
{
"data": [
{
"name": "myName"
}
]
}
I think you can use https://developers.facebook.com/docs/php/howto/profilewithfql/ to get an idea of how to query the FB.API to perform a FQL query.
FQL Guide: https://developers.facebook.com/docs/technical-guides/fql/
I am trying to get the JSON for the following soundcloud track listing page.
http://soundcloud.com/tags/Hiphop
The query I try to perform is
http://api.soundcloud.com/tracks.json?order=hotness&limit=20&created_at[from]=2012-05-18&tags=hiphop + consumer key.
All of the songs on that tags page are less than 3 days old, and I am ordering by hotness. The filters doesn't seem to work at all. The results of the query and the tags/Hiphop page are not even close. Am I missing something?
Unfortunately the created_at filter cannot be used with the order parameter. If you'd like to replicate the listing in the URL you provided, just make the following API request:
https://api.soundcloud.com/tracks.json?client_id=YOUR_CLIENT_ID&tags=hiphop&order=hotness
Or, in JavaScript, assuming you have a ul element with an id 'tracks':
var url = 'https://api.soundcloud.com/tracks.json?client_id=YOUR_CLIENT_ID&tags=Hiphop&order_by=hotness';
$.getJSON(url, function(data) {
$.each(data, function(index, track) {
$('<li />', { text: track.title }).appendTo('#tracks');
});
});