我正在做一个很棒的项目,通常我使用 AS3,但现在我使用的是 Javascript。
我有以下信息:下面我正在尝试访问检测线,基本上我需要的是检测(response.username)。我已经尝试了很多东西,有人可以帮忙吗?
<div id="fb-root"></div>
<script type="text/javascript">
$(document).ready(function(){
var appId = "121070974711874";
// If logging in as a Facebook canvas application use this URL.
var redirectUrl = "http://apps.facebook.com/bggressive";
// If logging in as a website do this. Be sure to add the host to your application's App Domain list.
var redirectUrl = window.location.href;
// If the user did not grant the app authorization go ahead and
// tell them that. Stop code execution.
if (0 <= window.location.href.indexOf ("error_reason"))
{
$(document.body).append ("<p>Authorization denied!</p>");
return;
}
// When the Facebook SDK script has finished loading init the
// SDK and then get the login status of the user. The status is
// reported in the handler.
window.fbAsyncInit = function(){
FB.init({
appId : appId,
status : true,
cookie : true,
oauth : true
});
FB.getLoginStatus (onCheckLoginStatus);
};
(function(d)
{
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
function onCheckLoginStatus (response)
{
if (response.status != "connected")
{
top.location.href = "https://www.facebook.com/dialog/oauth?client_id=" + appId + "&redirect_uri=" + encodeURIComponent (redirectUrl) + "&scope=user_photos,friends_photos";
}
else
{$
// Start the application (this is just demo code)!
$(document.body).append ;
FB.api('/me?fields=username', function(response) {
function detect(URL) {
var image = new Image();
image.src = URL;
image.onload = function() {
var result = 'result'; // An example result
}
document.body.appendChild(image)
}
detect("https://graph.facebook.com/" + response.username + "/picture?width=200&height=200");
});
FB.api('/me/friends?fields=id,first_name', function(response) {
var randomFriend = Math.floor(getRandom(0, response.data.length));
gFriendID = response.data[randomFriend].id;
var randomFriend = Math.floor(getRandom(0, response.data.length));
gFriendID2 = response.data[randomFriend].id;
function friend1(URL) {
var image = new Image();
image.src = URL;
image.onload = function() {
var result = 'result'; // An example result
}
document.body.appendChild(image)
}
friend1("https://graph.facebook.com/" + gFriendID + "/picture?width=200&height=200");
function friend2(URL) {
var image = new Image();
image.src = URL;
image.onload = function() {
var result = 'result'; // An example result
}
document.body.appendChild(image)
}
friend2("https://graph.facebook.com/" + gFriendID2 + "/picture?width=200&height=200");
});
}
}
});
</script>