Soundcloud has feature that allows any track to auto download if you add "/download" to the end of the track URL.
We have made use of that feature for many years on our soundcloud hosted podcast:
http://techzinglive.com
http://soundcloud.com/techzing
As of a few days ago the feature seems to have stopped working.
Now that we have 300 episodes it would be quite difficult to go back and retrospectively change the URLs by copy pasting the download link for each episode.
a) Is there any way Soundcloud could fix this?
b) Is there an alternative that does the same thing?
Example:
168: TZ Interview - Patrick Collison / Stripe
~~~
http://soundcloud.com/techzing/techzing-168 (regular link)
http://soundcloud.com/techzing/techzing-168/download (auto download link)
Note: I posted this here as directed by the soundcloud support page.
Well the answer to the question is that SoundCloud no longer support the download slug option. But you can get it to work using their API.
Backend (PHP)
<?php
$yourSoundCloudClientId = '<CLIENTID>';
$yourSoundCloudTrackUrl = 'http://soundcloud.com/techzing/techzing-001';
if ( ! $trackData = json_decode(file_get_contents("http://api.soundcloud.com/resolve?url={$yourSoundCloudTrackUrl}&client_id={$yourSoundCloudClientId}")) )
{
die('Could not get the track because Soundcloud is down, or somethign else weird is happening.');
}
header("Location: {$trackData->download_url}?client_id={$yourSoundCloudClientId}");
?>
Frontend (JS)
<head>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://connect.soundcloud.com/sdk/sdk-3.0.0.js"></script>
<script>
var yourSoundCloudClientId = '<CLIENTID>';
var yourSoundCloudTrackUrl = 'http://soundcloud.com/techzing/techzing-001';
SC.initialize
({
client_id: yourSoundCloudClientId
});
SC.get('/resolve?url='+yourSoundCloudTrackUrl).then
(
function(track)
{
$('#trackDiv').html('<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/'+track.id+'&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>');
}
);
</script>
</head>
<body>
<div id="trackDiv"></div>
</body>
Forgive the malformed HTML... but, you know, it works ;)
Related
Is this scenario possible?
Customer goes to my website, wants to download a PDF technical document that interests them, they click the Download button and a Facebook share window appears to log them in to share it to Facebook. Once they click Share and it is posted on their wall then the download begins?
Many thanks.
Ian
UPDATE
According to a Facebook new policy, this act is not allowed. Use it at your own risk. I hold no responsibilities for using this.
Yes, using the JavaScript SDK, it provides a response (it doesn't anymore)
We will create an if statement to see if the response has a post_id if yes show the download link else do something else (alert the user, maybe?)
DEMO (API 2.0) (not working; revision required)
DEMO (API 2.7) working Rev#63
HTML
<div class="container">
<div>
<p>This file is locked, to unlock and download it, share it</p>
<p class="hidden">Thanks for sharing, the file is unlocked and ready for download</p>
<p class="hidden">In order to download this file, you need to share it</p>
</div>
<a class="fsl fsl-facebook" href="#" id="facebook-share">
<span class="fa-facebook fa-icons fa-lg"></span>
<span class="sc-label">Share on Facebook</span>
</a>
<a class="fsl content-download" href="#" id="download-file">
<span class="fa-download fa-icons fa-lg"></span>
<span class="sc-label">Download File</span>
</a>
</div>
JavaScript (jQuery)
$('#ShareToDownload').on('click', function(e) {
e.preventDefault();
FB.ui({
display: 'popup',
method: 'share',
href: location.href,
},
/** our callback **/
function(response) {
if (response && response.post_id) {
/** the user shared the content on their Facebook, go ahead and continue to download **/
$('#ShareToDownload').fadeOut(function(){ $('#downloadSection').fadeIn() });
} else {
/** the cancelled the share process, do something, for example **/
alert('Please share this page to download this file'):
}
});
});
UPDATE
With the release of API version 2.0 the Feed dialog was deprecated and replaced with the new modern Share Dialog so the above code uses the new Share Dialog
Thank you, works perfect! I Didn't know how to get the download link from a JSON file, so I did it slightly different, maybe not that safe.
Add this to the section where the response is checked
$.post('optimus.php', { 'fieldname' : 'download', 'value' : 'yes'});
Made a new page where the session is set (optimus.php)
<?php
session_start();
$_SESSION[$_POST['fieldname']] = $_POST['value'];
?>
Download.php contains the following code
<?php
session_start();
if($_SESSION['download'] == "yes"){
session_destroy();
$file = 'file.zip';
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
} else {
echo "You didn't share, or you already downloaded the file";
}
?>
So, when the user shared something, the $_SESSION['download'] is set to yes. Download.php checks if it's yes and when it is the download is automatically started. Also, the session is destroyed so they can only download once.
I am trying to add a custom link to the [object] (marked in red, below) in a facebook custom Action post.
This is my code :
FB.api('/me/testapponens:cook', 'post',
{ recipe: 'http://foobar.com/page1.html' },
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Cook was successful! Action ID: ' + response.id);
}
});
Now, Because I have stated 'http://foobar.com/page1.html' in my 'recipe', when this is posted, the open-graph properties are picked from this page.
PROBLEM : I need to show the link as a thirdparty link www.thirdparty.com/page1.html but the open graph meta properties cannot be written in thirdparty.com/page1.html (as I don't have any control on that page).
So, I decided to do this:
i) Create a dummy page : www.foobar.com/page1.html.
ii) Add all the og meta to it.
iii) Add a redirect (javascript) code to the dummy page so that it goes to the third party page.
www.foobar.com/page1.html looks something like this :
<html ...>
<title> Page 1 </title>
<meta property="fb:app_id" content="..." />
...
<script type="text/javascript">
function redirect1()
{
window.location = "http://thirdparty.com/page1.html"
}
</script>
</head>
<body onLoad="redirect1()"></body>
</html>
QUESTION : I think this is a hacky approach and it may not be acceptable to the users. Is there a better way of doing this? Please let me know if I was not able to explain what I intend to do.
PS : I am not a spammer, the third party page is from a client and I am not trying to misguide the users.
I think this is a hacky approach and it may not be acceptable to the users. Is there a better way of doing this?
You can do a server-side redirect, checking the user agent – only if it is not indicating to be the Facebook scraper, redirect the client, otherwise let the scraper read the OG meta info from your page.
How to detect the FB scraper: https://developers.facebook.com/docs/reference/plugins/like/#scraperinfo
Hmm ... not sure why, but adsense ads aren't showing up on this site (http://dapperhawk.com). The code is exactly the same as is provided on the adsense site as far as I can tell:
<script type="text/javascript"><!--
google_ad_client = "ca-pub-1773904113940189";
/* bottom_results */
google_ad_slot = "0900749086";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Any thoughts on how one might troubleshoot this?
Just to follow up on this ... I sent an email to google support, and got a response that essentially said, "it looks like it's working now". I didn't change anything :-/
I am using FB:Comments on my page using XFBML. When I post a comment, an error comes up with the message "This comment has not yet been published to Facebook"
This is the code that I am using apart from the fb:comments tag
<div id="fb-root"></div>
<script>window.fbAsyncInit = function() {
FB.init(
{appId :'APP ID',status:true,cookie:true,xfbml:true});
};
(function(){var e=document.createElement('script');
e.async=true;
e.src=document.location.protocol+'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);}());
</script>
It looks this problem comes with ".info" domains.
Or it might be that this happens with top level domains with 4 or more letters, like .info, .name or .mobi, though I haven't investigated into all of them.
What attributes do you have set on the fb:comments tag? I believe all that's doing is the facebook connect/login side of things. Have you got the correct OG tags in place? You could also add in code to subscribe to the add comment event and see what's going on:
<script>
FB.Event.subscribe('comments.add', function(resp) {
for(var i in resp){
if(resp.hasOwnProperty(i)){
console.log(i + " " + resp[i]);
}
}
});
</script>
you may also need the channel file as detailed here https://developers.facebook.com/docs/reference/javascript/
I'm having the same problem. If I use the example page (http://developers.facebook.com/docs/reference/plugins/comments/) the comment gets posted on my wall, whereas doing the same in the comment box of my app does not, unless I pint them to a Facebook URL.
This works:
<fb:comments href="http://www.facebook.com/any-url/" ></fb:comments>
This doesn't if I do it from my app, but it works if I do it from my site (which doesn't really help for the purpose I need it to)
<fb:comments href="http://www.mysite.com/any-other-url/" ></fb:comments>
I'm having an issue connecting to Facebook through the Javascript Client Library in Adobe AIR. It works fine in the browser but in Adobe AIR it seems to not be able to find the Facebook functions. Here is some code I copied from the Facebook website: (Oh and I have the xd_receiver.htm file in the correct path too)
<textarea style="width: 1000px; height: 300px;" id="_traceTextBox">
</textarea>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
//
var api = FB.Facebook.apiClient;
// require user to login
api.requireLogin(function(exception){
FB.FBDebug.logLevel=1;
FB.FBDebug.dump("Current user id is " + api.get_session().uid);
// Get friends list
//5-14-09: this code below is broken, correct code follows
//api.friends_get(null, function(result){
// Debug.dump(result, 'friendsResult from non-batch execution ');
// });
api.friends_get(new Array(), function(result, exception){
FB.FBDebug.dump(result, 'friendsResult from non-batch execution ');
});
});
});
//]]>
</script>
It's not that simple actually man, the problem with loading external script files from the application sandbox is that it's not supported. Technically, by using iframes, you should be able to do this and it works but it's still impossible to use XFBML in the root document after from my experience. After two days of trial and error, the easiest way to do use Facebook Connect in an html/ajax adobe air application is to download the actionscript library and include it as such:
<script type="application/x-shockwave-flash" src="lib/facebook.swf"></script>
<script type="text/javascript">
var FB = window.runtime.com.facebook;
var fb = new FB.Facebook();
var session = new FB.utils.DesktopSessionHelper();
//etc...
</script>
then just refer to the documentation. my only problem now it that I still haven't found an efficient enough way of using XFBML in adobe air, simply adding the facebook namespace to the html tag doesn't do the trick unfortunately. If any knows, please do share thanks
you also need to change xml namespace (main html tag) to this:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en-gb" lang="en-gb">