作者筆記
這裡主要是分享小編的小小心得與筆記,不論是日常生活亦或是應用開發,只要是有用的,小編也會在這裡寫寫教學。希望你也能夠有所得著。
對本篇文章發表意見
作者筆記
FACEBOOK ids_for_business JSON 的讀取筆記
FACEBOOK ids_for_business JSON 的讀取筆記
記錄用
function detail() {
FB.api('me/ids_for_business', function(response) {
console.log(JSON.stringify(response));
var obj = eval ("(" + JSON.stringify(response) + ")");
document.getElementById('detail').innerHTML = obj.data[0].app.id;
});
}
FB.api('me/ids_for_business', function(response) {
console.log(JSON.stringify(response));
var obj = eval ("(" + JSON.stringify(response) + ")");
document.getElementById('detail').innerHTML = obj.data[0].app.id;
});
}
FACEBOOK調用以上JAVA SCRIPT時,
會獲得一組JSON如下框的例子
{
"data": [
{
"id": "10153949089790582",
"app": {
"name": "Business's App 1",
"namespace": "business_app_1",
"id": "647733625268125"
}
},
}
"data": [
{
"id": "10153949089790582",
"app": {
"name": "Business's App 1",
"namespace": "business_app_1",
"id": "647733625268125"
}
},
}
首先把這組JSON存到var obj
而obj.data[0].app.id則代表讀取obj中的data資料[0]的app的id
輸出的結果將會是647733625268125
資料報導BY青怡:https://yeeapps.com/