Hey guys i am trying to make a facebook application..When a user is logged in and if a music is played or playing it must be detected by the app and the action must come in the recent activity of the user..So for this i have went through http://ift.tt/1C8tQl2
So i have made a code with music.listen
with the api call..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>
function statusChangeCallback(response) {
if (response.status === 'connected') {
var myAudio = document.getElementById('music');
if (myAudio.duration > 0 && !myAudio.paused) {
testAPI();
} else {
console.log('music isnt playing')
}
}
}
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,
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,user_actions:music" onlogin="checkLoginState();">
</fb:login-button>
<div id="status">
</div>
</body>
</html>
This code works just perfect without any errors but the function testAPI();
isnt working.. and the music isnt detecting by the app..
Any help would be greately appreciated ..Thanx
Aucun commentaire:
Enregistrer un commentaire