Getting Facebook event information from URL - facebook

I've been reading some stuff about Facebook API's but as a non-programmer it's kinda hard to understand it all. It's probably a pretty simple question.
My question: is it possible to get all the information like coverphoto, time, description, location etc. from a (random) public Facebook event from just the URL of the event?
So I will have a field 'Insert event URL' on my page. Below that I will have some fields like 'Location' 'Start time' 'End time' which will be automatically filled in when the user inserts the URL of an event.
Please let me know! A link to the source with explanation etc. would also be really nice. (It's for a school project)

Yes you can. Ill try to explain you the simplest possible way to do that.
First of all go to : http://developers.facebook.com/apps and create an app.
Then, save the App access token which is: app_id|app_secret
Your url will be of format: https://www.facebook.com/events/{event-id}. Fetch the event id from this. Quite simple right?
Then you are going to use the facebook's powerful graph api. Just get the contents from : https://graph.facebook.com/{event-id}?access_token={app-access-token}
The list of all possible fields that you can get (only if set in the event of-course): https://developers.facebook.com/docs/graph-api/reference/user/events/#pubfields
That's it!

Related

Getting a SoundCloud API client ID

Encountered a problem accessing my tracks from browser.
Usually i type this link in my browser to access downloadable tracks:
http://api.soundcloud.com/tracks/294324164/download?client_id=02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea
But now i can not access it anymore, probably the client id is changed.
How can i obtain a new client id?
Thanks.
Simple.. Go to any tracks that you can download on soundcloud, press f12 and look at networks tab, click download and it will show you something like
https://api.soundcloud.com/tracks/322109493/download?client_id=2t9loNQH90kzJcsFCODdigxfp325aq4z&oauth_token=2-274121-85658-y9KQYyZ6qG9oT2uvPq
Grab that client_id, replace it and amend the url from download? to stream?.. use streams? if you want a list of urls in json format
http://api.soundcloud.com/tracks/294324164/stream?client_id=2t9loNQH90kzJcsFCODdigxfp325aq4z
As no one else has mentioned it, in a Chrome-based browser under DevTools ctrl+shift+i, you can grab your client_id from the Network tab on reload. Many items listed here reference the SoundCloud API and require your client_id to access it. Simply click any item in the list that isn't an image/base64 item (preferably something that begins with id?...), then check the Request URL for a client_id.
It's the simplest way to grab the ID; now that you know how, don't do anything illegal k thx.
For those thinking this is the same as the other answer mentioning a download link, this method skips that entirely as many songs are no longer available from SoundCloud itself, but from external sources that are linked instead.
Amazing it's been this long, yet there's no "public" Soundcloud API. I'm amazed to find something worse off than the Twitch API.
See this user's solution for a way to do this without a CLIENT ID which you can no longer get from soundcloud: https://stackoverflow.com/a/27461646/179571
youtube-dl https://soundcloud.com/my-fav-artist
seems to work and pull all tracks as mp3
no client_id needed, if you needed the client_id to get something
like soundcloud-dl to work
You can apply for a client ID by filling in the SoundCloud Application Registration form.

Get share/like count for different url/bogposts/articles

I am looking for a method to get share/like count for each of the blogposts/articles which I create on my website. Interested in Facebook, LinkedIn and Twitter but Facebook is the most important right now.
Lets take this website as an example: https://googleblog.blogspot.com/
I have found a method to find this out for each url, but that will make it a lot harder for me as I would need to do it manually for each URL.
This is the query I used to get data for a specific URL:
https://graph.facebook.com/v2.7/?id=https://googleblog.blogspot.no/
Is there any method to get data for each and every url which contains: "company name" or something like this?
Will appriciate all the help I can get here.
No, there is no “wildcard” for Open Graph object URLs.
You can however request data for multiple URLs in one go, using the ?ids=foo,bar syntax – https://developers.facebook.com/docs/graph-api/using-graph-api/#multiidlookup
This theoretically works for up to 50 ids in one request (although with the ids being URLs in this case, you might only be able to request less, due to URL length limitations.)

Facebook Graph API tag friend(s) while post message

I want post some message and tag friends like facebook (web version) does. For example, "simple message #SomeUser". So the question is: how can i tag friends and what is the easiest way to do that?
As i understand there are two ways to do that:
1) https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed#pubfields but i don't understand why should i provide place id in order to tag friends and where to get (or generate ???) it. Moreover i don't understand where should i get user id. https://developers.facebook.com/docs/graph-api/reference/v2.1/user/taggable_friends? I don't know because request always fails.
2)https://developers.facebook.com/docs/opengraph/using-actions/v2.1#mentions ? I've tried #[userTaggingToken] and replaced userTaggingToken with user id from /user/taggable_friends. But it doesn't work too. Moreover, user id from /user/taggable_friends is much longer than one provided by example.
I abstract from any sdk so please don't refer to any programming language (and its SDK). Any links to documentation and examples with concrete requests (like .../v2.1/user/feed) and data should be passed (message="...") are welcome.

Send the user to a page along with a error message

I want to set up a login page in which from anywhere on the site I can send a user to it and it will display a custom message along with it. I could use a redirect and a msg query param but is this the best way to do it?
I'm working with node.js but I'm interested in a universal solution.
If you are going for easy, you can just have GET data in the URL. But, that doesn't look that nice, if you want a rather long message, plus, GET has size restrictions, where POST (virtually) hasn't.
For using post data you could use the solution of this: JavaScript post request like a form submit question, but that gives a rather messy source code (if you want a somewhat longer text).
You could keep them in a database, and only send the ID of the message to a PHP page, and get it from the database (that's what I would do, but that doesn't mean it's a good idea, just amateur here!)
You can use jQuery or simply plain javascript to extract your message from the url; the relevant question that listed links to detailed code: jquery get querystring from URL.
Then depending on how you want it displayed, apply the extracted string to your situation.

How do I transfer Comments from one Facebook App ID to Another?

Is there any way to transfer comments from a "deleted" Facebook app (that is still receiving comments) to a new app id? The app was deleted by accident quite some time ago but we now have thousands of comments that have been entered using it. I'm afraid I will lose all of the comments if I simply switch to a new app. The app id seems to function just fine with the commenting mechanism, but I can't manage it or use it in any other way.
AFAIK, there is no automated way of doing this. However, you can read them programatically from your deleted app (provided you have the permissions) and then post it again on your new app.
You can get the original app's feed using the following (PHP) code:
$response=file_get_contents("https://graph.facebook.com/".$id."/feed&access_token=".$facebook_access_token);
$response_array=json_decode($response,true);
// $id: ID of the page where the comments are
You can also customize this query by adding pagination parameters like since,limit,until etc. Please refer to https://developers.facebook.com/docs/reference/api/ for documentation.
And can be reposted to your app by HTTP POSTing to the same URL. See https://developers.facebook.com/docs/reference/api/page/#posts for details.
Please understand that you can't post as the original author - so you can only post the text and perhaps manually add the context of the original author. so i.e:
"Shreeni: 'This is a cool app' "
will have to become
"App: 'Shreeni said: 'This is a cool app' ' "