我为登录用户抓取FB好友的数据。
//我获取当前用户的详细信息
$.getJSON(url,function(json){
var html = "<ul>";
var manager_email;
var manager_name;
var manager_birthday;
var manager_fbuid;
var accessToken = window.location.hash.substring(1);
var email_url = "https://graph.facebook.com/me?"+accessToken
$.getJSON(email_url,function(user){
manager_email = user.email
manager_birthday = user.birthday;
manager_name = user.name;
manager_fbuid = user.id;
html += "<li>" + manager_email + "</li>";
html += "<li>" + manager_birthday + "</li>";
html += "<li>" + manager_fbuid; + "</li>";
html += "<li>" + manager_name; + "</li>";
$('.facebookfeed').html(html);
});
//然后我遍历好友列表并将信息放在页面上的表格
$.each(json.data,function(i,fb){
var pic_url = "http://graph.facebook.com/"+fb.id+"/picture";
html += "<form id='new_celebration' method='post' action='/celebrations' accept-charset='UTF-8'>";
html += "<input type='hidden' id='name' value='"+fb.name +"' name='celebration[name]' />"
html += "<input type='hidden' id='fbuid' value='"+fb.id +"' name='celebration[fbuid]' />"
html += "<input type='hidden' id='pic_url' value='"+pic_url +"' name='celebration[fb_picture]' />"
html += "<li>" + manager_email + "</li>";
html += "<li>" + fb.name + "</li>";
//could be undefined if user does not want to share this information
if(fb.birthday != null){
html += "<input type='hidden' id='birthday' value='"+fb.birthday +"' name='celebration[birthday]' />"
html += "<li>" + fb.birthday + "</li>";
}
html += "<li><img src="+pic_url+" /></li>";
html += "<input class=button-mini-subtle' type='submit' value='select' alt='select' class='submit'>";
html += "</form>";
});
</script>
<p id="userName"></p>
<p class="facebookfeed"></p>
我想要做的是将manager_email,manager_name,manager_fbuid附加到提交的表单数据中。
我该怎么做?