Issue in fetching SoundCloud Tracks using the HTTP API - soundcloud

Iam using this link as reference to fetch tracks uploaded on my account to play them in my app.
It is clearly written in the guide that "To access public resources you just have to pass a client_id parameter" in the following URL
https://api.soundcloud.com/tracks?client_id=YOUR_CLIENT_ID
I have created an app on my SoundCloud account and passed the Client ID generated there in the above URL. I am getting around 50 tracks, but unfortunately none is from my PlayList/tracks.
I also tried to create multiple apps and use their Client ID, but no success.
Kindly point out if I am missing something OR should I follow some other approach.
My purpose is to fetch the tracks that are uploaded on my SoundCloud account.
Regards.

The url that you provided is used to fetch details about specific track by passing additional id parameter.
To fetch tracks uploaded by specific user, you should use:
http://api.soundcloud.com/users/[USER ID]/tracks?client_id=YOUR_CLIENT_ID

Related

Find out whether Facebook page is live streaming

Is possible to find out whether some facebook page is live streaming right now? I was looking at Facebook API and from there it seems to me that it is not possible since /{page_id}/live_videos seems to be working only if you are an admin of the page (or you have been granted the access) since you cannot read live videos of public without page access token.
Yes, you can. This is actually called a WebHook (simultaneous notification of a certain app/user about changes made on the page). To do this you will have to create a Facebook App that will be subscribed to the changes made on a certain page that you want to track.
You can simply do this from the dashboard of the app or through Graph API 2.7(since this version supports live_videos) calling {app-id}/subscriptions and choose any of Page Object Subscriptions, which are available through Facebook API(in your case live_videos).
For this kind of subscriptions your app needs to be whitelisted in order not to spam or re-transmit the information received from a certain page.
To get more information about WebHook implementation please read Facebook API documenation: https://developers.facebook.com/docs/graph-api/webhooks
I know this is quite late already but for those that may stumble on it like I did, Yes it's possible.
As clearly stated in the documentation
Page Live Videos - Facebook API Documentation
You will need to make a GET Request to the endpoint below with the appropriate parameters:
https://graph.facebook.com/v6.0/{page-id}/live_videos
Where page_id is the Facebook Page ID you with to check for active Live Stream
The endpoint also expect broadcast_status whose value for your use case would be LIVE
Note: You will need and app setup on Facebook for developers platform and your query would have to be via the app
Further details can be found in the documentation whose link I provided at the initial part of this answer.
You might be able to get a returned string if there is any, from:
GET /v2.7/{page-id}/live_videos HTTP/1.1
Host: graph.facebook.com
You can read more in: https://developers.facebook.com/docs/graph-api/reference/page/live_videos/

How to use Facebook Embedded Post to show the latest post using Graph API?

I want to show a Embedded Post in my website, but I want it to be always the latest post on my fanpage.
What I'm trying to do is:
Query the posts by making a GET request to https://graph.facebook.com/{FANPAGE}/posts?access_token={TOKEN}
Get the ID of the first object
Add the plugin to DOM on runtime using the ID
The problem is that I can't figure it out how to get a permanent access token (or equivalent) - since I can't update it every time it expires and I don't want the user to login just to be able to see the plugin.
Can this be done? How?
You can use a page access token, or your app access token (the latter will work only if the page is not restricted and posts are not targeted to specific audiences.)
Both of those must never be exposed in public client-side code; so you will need to do this on the server.

How to get Facebook share count for all links shared using a given application via Facebook API

Is it possible to get a list of statistics/analytics for all the links shared using a server-side Facebook application via the Facebook API?
I have a list of links that can be shared to Facebook using the appId defined in my server app. In order to refresh the share count of those items, I'm currently calling:
http://graph.facebook.com/{MY_URL}
whenever I want to update those values.
Obviously, this solution is not very scalable, because the number of items constantly grows so I can't call the method on all the URLs in sequence. Alternatively, this information can be fetched every time it needs to be visualized to the users. However, this can mean that the same request will be made to Facebook API in quick succession even though the chances of anything changing are small.
Ideally, I would like to get a list of all the links/items shared using my application with the share count for each of them. This way I can do a nightly update of all the values without going one by one.
I'm using the
me/links
API method to share the links to Facebook.
Analytics of a post, shared by a page can be accessed by the Insights API
Below id the Graph API call to access the count of clicks sent to your domain by a certain post.
/v2.4/<object-id>/insights/domain_feed_clicks?period=lifetime
If this is not what you're looking for, please refer to the permalink mentioned above and find the metric which best suits your need.
I would like to get a list of all the links/items shared using my application
The API does not provide that kind of list.
To reduce the number of API requests you have to make, you can request the data for several URLs in one go though: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#multirequests
https://graph.facebook.com/?ids=http://example.com/foo,http://example.com/bar,…
(You should properly URL-encode any URLs you use a parameter values here of course.)

Add extended permissions - Facebook

I created a Java program that retrieves users personal information and posts. I can retireve everything related to me but not to my friends.
I know that i have to add some extended permissions to collect information about my friends (e.g. friends_groups, friends_interests, friends_subscriptions and more) but i don't know how to add them.
I didn't use Facebook Api in my Java application. I just give a specific URL, for example :
https://graph.facebook.com/friendID?access_token=MY_ACCESS_TOKEN_HERE
and i get a JSon Object from this URL which contains the information of that user (id, first_name,last_name,link,name,updated_time) which are not useful for what i want to do.
I also tried :
https://graph.facebook.com/friendID?access_token=MY_ACCESS_TOKEN_HERE&scope=friends_activities,friends_birthday,friends_status,friends_subscriptions,friends_work_history
but again it didn't work either to my Java App or Graph Api Explorer.
Can someone explain to me how to add the extended persmissions that i need provided that i created my app in the way i explained above? Can i add the permissions inside the URL that fetches the JSon Object?
To get a person's data, your app needs to use that person's access token. To get that person's access token, that person must authorize your app (through Facebook Login). You can read more about Facebook Login in the documentation.

As a developer, can I browse posts published through my app?

I found the section below on Facebook Developer. Does Facebook provide a way for me to browse the posts by my users, or do I need to store the post ID and write my own dashboard?
It depends which SDK you are using. In general, Facebook does not offer a solution on their own, and if you are using the JavaScript SDK for the postings there is no way to get to the message.
That being said, the only way to get the messages posted via the JS SDK is the following:
The user has to authorize your app
You have to store the access token of the user
You have to store the Post-ID of every post so you can make an API call to get the message
Remember that those user access tokens are valid for ~2 hours only, so you have to use an extended one (up to 60 days valid). After those 60 days there is no way to read the messages anymore, so you would have to store them in your database if you need/want them later. Also keep in mind that the user can remove your app and invalidate the token.
If you are using the PHP SDK for posting (which only works for users who authorized your app), then you can just store the message value in your database because you need to get the message anyway (from a textfield, for example). But be sure to tell the user what you will store, also why and for how long, for privacy reasons.
Summary: The only way to do this (without getting problems with access tokens) is to let the user authorize your app, after every publish you have to use the new post id to get the message with an API call and to store it in your database. This is valid for the PHP SDK and the JS SDK.
Yep, there's no way rightnow, by which you can view the posts published through you're app. The only way you can achieve this is by storing the post_id for every published post, and create a script that will fetch the posts data, when provided with the post_id's