I am trying to use stream function as displayed on example(taken from SDK http://developers.soundcloud.com/docs/api/sdks#javascript)
SC.stream("/tracks/293", function(sound){
sound.play();
});
But it does not work and gives 404 error:
GET http://connect.soundcloud.com/soundmanager2/soundmanager2_flash9_debug.swf 404 (Not Found)
As of the JavaScript SDK version 3.3.0, this is working as intended. Make sure to initialize the SoundCloud client with your Client ID:
SC.initialize({
client_id: '{CLIENT_ID}'
});
SC.stream('tracks/293').then(function(player) {
player.play();
});
Related
I am trying to add facebook authentication on our website using Facebook Javascript SDK v2.10. My aim is to login via Facebook and then fetch the user which was authenticated.
The problem I am facing is that on Firefox, I am unable to fetch the authenticated user.
I have created a test page HERE
When you click on the button 'Login via Facebook', the FB.login function is called. When the response is received, I am calling the FB.api function. Following is my code
FB.login(function(response) {
let p1 = document.createElement('p');
p1.innerHTML = "FB.login response follows:<br>"+ JSON.stringify(response);
document.body.appendChild(p1)
FB.api('/me', {fields: 'id,first_name'},
function(response) {
let p2 = document.createElement('p');
p2.innerHTML = "FB.api response follows:<br>"+ JSON.stringify(response);
document.body.appendChild(p2)
});
});
In Chrome,the callback of FB.api is called and the response is received,but, in Firefox, this is not happening. Kindly help me figure out why this is happening
Ok. I was using Facebook sdk in Polymer app. The sdk documentation suggests adding the sdk initialization code in index.html.
But, for Polymer, you need to add the code in the connectedCallback method of your root app (my-app.html if you are using polymer-starter-kit)
For reasons unknown, the webcomponent-loader.js blocks Facebook initialization on Firefox, if sdk code is added in index.html.
One benefit of node js that we can use the ready made huge base of javascript libraries? So, I was wondering how to integrate the Facebook sdk at http://connect.facebook.net/en_US/sdk.js into my node project?
I am a bit new to Node so the question might be naive..
You cannot integrate the Facebook SDK directly. There are some libraries at http://npmjs.org which deal with Facebook connectivity, but most of them are quite old.
If you're just looking for Facebook Login integration, https://www.npmjs.org/package/passport-facebook could be a starting point.
I ended up developing my of "library", which is not too complicated because the Facebook Graph API can be used via standard HTTP requests.
Try this .
First do npm install facebook-nodejs-sdk
And then
var connect = require('connect'),
fbsdk = require('facebook-sdk');
connect()
.use(connect.cookieParser())
.use(connect.bodyParser())
.use(fbsdk.facebook({
appId : 'YOUR APP ID',
secret : 'YOUR API SECRET'
}))
.use(function(req, res, next) {
if (req.facebook.getSession()) {
res.end('Logout');
// get my graph api information
req.facebook.api('/profile', function(me) {
console.log(me);
});
} else {
res.end('Login');
}
})
.listen(9000);
I am trying to get user information..and I'm using this method
FB.api('/me', function(response) {
console.log(response);
});
but the problem is that the response contains a wrong user_id.
Probably you're using Login 2.0 respectively the new JS SDK (https://developers.facebook.com/docs/javascript/quickstart/v2.0) and are getting an app-invidual user_id as described in the Graph API v2.0 Upgrading Guide:
https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
I am trying to do a JavaScript login from my iPhone 4 running Chrome for iOS version 26.0.1410.53 but I'm getting an error as seen below.
Here's the live URL to replicate on iPhone - http://mni.me/master
Click on "Get your own homepage like this"
Click on "Login with Facebook"
Here's my JavaScript
FB.getLoginStatus(function(r) {
if (r.status !== 'connected') {
FB.login(function (response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
} else {
console.log('User cancelled login or did not fully authorize.');
}
});
} else {
console.log("User alredy connected with FB app. Checking if user is in DB");
var url = 'api/isUser.php?fid='+r.authResponse.userID;
isUser(url);
}
});
It's working fine on Chrome for Desktop, but I'm getting this error on iPhone...
What is the problem and how can I fix it?
It's been around since Chrome 19.
Check here https://developers.facebook.com/bugs/325086340912814/ for more details.
I'm not sure if there will be a workaround or fix soon.This issue was logged about 10 months ago.
https://code.google.com/p/chromium/issues/detail?id=136610
I've been struggling with this for awhile.
This may not be a perfect solution but I was able to get around this by getting the login url using the PHP SDK (https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/) and linking that to the Facebook button. It works on Chrome mobile.
I'm not sure if there's an equivalent to the getLoginUrl for the JS SDK.
I want to submit a form from my Facebook canvas app via ajax.
If I run my app outside of facebook, it works fine. However, if I do the ajax call running as a Facebook canvas app, the user is redirected to the the ajax post url!
The server response is valid json.
I've spent over an hour on this.
I found that Facebook has a deprecated FBJS ajax api. The new js api does not provide any ajax functionallity. The documentation on the deprecated API listed above states:
If you are building a new app on Facebook.com, please implement your
app using HTML, JavaScript and CSS.
What is the magic recipe to make an ajax post from a canvas app?
The relevant code boils down to this:
$(function () {
$('form').submit(function () {
if ($(this).valid()) {
$.ajax({
url: this.action, // I tried also submitting to the apps.facebook.com/... url, but it made no difference
type: this.method,
data: $(this).serialize(),
success: function (result) {
$('#result').html(result);
alert('TESTING - WORKS!!');
}
});
}
return false;
});
});
A night's sleep does wonders to your mind. It was very late yesterday when I posted this question.
When I woke up this morning I knew what to check for. The action I was posting to via ajax was in a controller that required Facebook authentication... Moved the action to a different controller and it now works. solved