mercredi 1 avril 2015

Song play not detecting with facebook

Hey guys i have wrote a code for detecting a music with facebook js sdk..If the music starts playing i just want to see that "user played musicname in the recent activity.


The code is



<html>
<head>
<meta property="og:audio" content="http://ift.tt/1GfRSRj" />
<meta property="og:audio:type" content="audio/vnd.facebook.bridge" />
<audio src="http://ift.tt/1GfRSRj" id="music" controls autoplay></audio>
</head>
<body>


<script type="text/javascript" src="//connect.facebook.net/en_US/sdk.js">

var myAudio = document.getElementById('music');
if (myAudio.duration > 0 && !myAudio.paused) {
testAPI();
} else {

console.log('music not playing');
}

function statusChangeCallback(response) {
console.log('statusChangeCallback');


if (response.status === 'connected') {
// Logged into your app and Facebook.
testAPI();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {

document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}

function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});


}
window.fbAsyncInit = function() {
FB.init({
music: true,
playing: true,
song: 'http://ift.tt/1GfRSRj',
start_time: '2011-05-05T13:22',
expires_in: 182,
radio_station: 'blah',
user_id: 100003281668772,
appId : '289533237896176',
cookie : true,

xfbml : true,
version : 'v2.2'
});
};

(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


function testAPI() {
FB.api(
"/me/music.listens",
"POST",
{
"song": "http://ift.tt/1GfRSRj",
"radio_station": "phew",
"album": "sunburn",
"playlist": "yeah",
"musician": "blah"
},
function (response) {
if (response && !response.error) {
console.log(response);
}
}
);
}
</script>
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>

<div id="status">
</div>

</body>
</html>


When i run this code it doesnt give me any error but the music isnt detecting..


Any help would be greatly appreciated Thanks


Aucun commentaire:

Enregistrer un commentaire