Embed HTML5 widget from normal soundcloud URL - soundcloud

I'm trying to turn submitted Soundcloud links on my website into SoundCloud HTML5 players. I read that this is possible with oEmbed but haven't gotten it to work myself yet. What I know is that I should use the following oEmbed URL:
http://soundcloud.com/oembed?format=js&url=[escaped_url]&iframe=true
However, I have no idea what to do with it. When I have an escaped SoundCloud URL and replace it with [escaped_url], what's my next step? How do I exactly use that link to generate the SoundCloud HTML5 player?

Send a request to that URL, and the response will be a JSON file containing all the information you need to create the widget.
Here's an example:
$ curl http://soundcloud.com/oembed\?format\=js\&url\=https://soundcloud.com/spadgos\&iframe\=true
({
"version": 1.0,
"type": "rich",
"provider_name": "SoundCloud",
"provider_url": "http://soundcloud.com",
"height": 450,
"width": "100%",
"title": "nickf \u2603",
"description": "",
"thumbnail_url": "http://i1.sndcdn.com/avatars-000005187616-3e82aa-t500x500.jpg?b96a101",
"html": "\u003Ciframe width=\"100%\" height=\"450\" scrolling=\"no\" frameborder=\"no\" src=\"http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fusers%2F6431392\u0026show_artwork=true\"\u003E\u003C/iframe\u003E",
"author_name": "nickf \u2603",
"author_url": "http://soundcloud.com/spadgos"
});
Just grab the html property and stick that in your document and that should be it.

Related

Facebook graph how to set parameters for picture?

I want to get user picture URL, but instead i get image download. In facebook developer guide It says to set redirect parameter to 0 but i don't know how to set parameters in graph, i tried it in JavaScript to but i still get picture downloaded not the URL any example, how to set parameters?
Here is what i tried:
/me?fields=id,name,picture?redirect=0
It returns syntax error.
The simple request returns image download
me?fields=id,name,picture
This is the example result:
"picture": {
"data": {
"height": 50,
"is_silhouette": false,
"url": "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=3008732859171455&height=50&width=50&ext=1587125741&hash=AeSgpchLcdbLL1Mt",
"width": 50
}
}
/me/picture would be the correct endpoint, or /me/picture?redirect=false if you do not want to redirect.
Source: https://developers.facebook.com/docs/graph-api/reference/user/picture/

Get scraped data from facebook graph api using url reliably

My app needs to get data facebook scrapes from URLs. Up until now we were getting it using
POST /?id={object-instance-id or object-url}&scrape=true
Which is detailed in updating object section in https://developers.facebook.com/docs/sharing/opengraph/using-objects
For example
POST /?id=http://google.com
{
"url": "http://www.google.com/",
"type": "website",
"title": "Google",
"image": [
{
"url": "http://www.google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png"
}
],
"description": "Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.",
"updated_time": "2015-10-06T11:34:58+0000",
"id": "381702034999"
}
Notice image section.
Unfortunately if og tags are configured wrongly on the server
POST /?id=http://some.page.with.bad.tags.com
{
"error": {
"message": "Invalid parameter",
"type": "FacebookApiException",
"code": 100,
"error_subcode": 1611016,
"is_transient": false,
"error_user_title": "Object Invalid Value",
"error_user_msg": "Object at URL 'http://some.page.with.bad.tags' of type '' is invalid because the given value '/some-bad-value' for property 'og:url' could not be parsed as type 'url'.",
"fbtrace_id": "abcabcabc"
}
}
Which returns nothing interesting.
Attempt to GET the url returns this:
{
"og_object": {
"id": "381702034999",
"description": "Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.",
"title": "Google",
"type": "website",
"updated_time": "2015-10-06T11:40:04+0000",
"url": "http://www.google.com/"
},
"share": {
"comment_count": 2,
"share_count": 13494003
},
"id": "http://www.google.com"
}
Which misses image section. I cannot find in the documentation any way to retrieve result with images without using POST /?id={url}, but that fails on any errors in og tags.
GET /{ObjectId}
returns only type and created_time
Entering the same broken link in https://developers.facebook.com/tools/debug/ results in page which contains image, description, title and captions for the page. Which I need. So it means facebook stores them, even though page has wrong tags, but I need a way to fetch them. Unfortunatelly I cannot provide link for broken url due to NDA, and I couldn't find other page with broken tags.
If the page contains invalid Open Graph markup this seems expected, also do not confuse the Graph API with some sort of datasource or a scraping service you can utilize to generate the preview for web content.
If Facebook , for whatever reason, can't parse the Open Graph tags of a URL it will try to make a good guess based on the content of the page (large junks of text, images it finds, title tags etc.) to build the preview so you might get some sort of data back from GET /{object-id} which can just be a guess instead of actual og:.. data.
In case you really need a more or less failsafe solution, you could build your own scraper that looks for Open Graph tags.

Set Size of SWF posted to Facebook with Feed Dialog

Is there a way to set the dimensions of a swf posted to Facebook using the feed dialog, either javascript or direct url method?
https://developers.facebook.com/docs/reference/dialogs/feed/
I'm not 100% certain that this works anymore as I've tried to add this with the Feed dialog as opposed to the sharer and it seemed to have no effect at all. It may have been replaced by the source parameter in the newer feed dialog API (which I don't think you can define a width/height for. Please correct me if I'm wrong) ..
but,
take a look at media attachments in the stream attachment guide:
https://developers.facebook.com/docs/guides/attachments/
you would pass in a JSON encoded object as the media URL param.
{"media": [{
"type": "flash",
"swfsrc": "http://www.mapsofwar.com/photos/EMPIRE17.swf",
"imgsrc": "http://icanhascheezburger.files.wordpress.com/2009/04/funny-pictures-hairless-cat-phones-home.jpg",
"width": "80",
"height": "60",
"expanded_width": "160",
"expanded_height": "120"
}]}

Facebook – Does a page exist for this URL?

I'm making a webpage/SEO checking page, where I can put in a URL and it will tell me various facts about the page.
I'd like to be able to tell if there is a Facebook page associated with the URL. Is this possible using the API, or by other means?
For instance, https://www.facebook.com/focalstrategy links to http://www.focalstrategy.com/ on the info tab – is there a way to go the other way and enter the URL and find the page(s)?
(Bonus points – anyone know of a way to do the same for Twitter accounts)
I don't think this is possible. Using the API, you can retrieve info about the url:
http://graph.facebook.com/?id=http://www.focalstrategy.com/
Would return:
{
"id": "http://www.focalstrategy.com/",
"shares": 38
}
Now I'm note sure if using the Open Graph Meta Tags would help return more data (still not what you need), but here is my website info without trailing slash:
http://graph.facebook.com/?id=http://www.masteringapi.com
Would return:
{
"id": "109784969102047",
"name": "MasteringAPI.com",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/276619_109784969102047_474156823_s.jpg",
"link": "http://www.masteringapi.com/",
"likes": 25,
"category": "Website",
"website": "http://www.masteringapi.com",
"description": "Master Facebook, Google and Twitter APIs! Learn Facebook Application Development Now!",
"can_post": true
}

How I can give a link to the caption of audio post on the wall

Hey!! I have made an application through which I am publishing an audio file to the wall in facebook. Further I want to give a clickable caption, that when get a click take me to some url. Can somebdy plz help me in sorting it out....
Thanx in advance...!
You need to send media as an attachment with your publish request.
{"media": [{
"type": "music",
"src": "URL_OF_MEDIA",
"title": "NAME_OF_AUDIO_CLIP",
"artist": "ARTIST",
"album": "ALBUM"
}]}
Docs here: http://developers.facebook.com/docs/guides/attachments