<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"zh-TW"
xml:lang=
"zh-TW"
>
<head>
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<title>Jsonp dynamic</title>
<script type=
"text/javascript"
>
function
googleplus(json) {
document.getElementById(
"gplus"
).innerHTML = dump(json);
}
function
getGplus() {
var
removeScript = document.getElementById(
'jsonScript'
);
if
(removeScript)
removeScript.parentNode.removeChild(removeScript);
var
uid = document.getElementById(
'uid'
).value;
var
key =
"Your key"
;
var
script = document.createElement(
'script'
);
script.type =
'text/javascript'
;
script.id =
'jsonScript'
;
script.src =
"https://www.googleapis.com/plus/v1/people/"
+uid+
"?key="
+key+
"&callback=googleplus"
;
document.getElementsByTagName(
'head'
)[0].appendChild(script);
}
function
dump(arr,level) {
var
dumped_text =
""
;
if
(!level) level = 0;
var
level_padding =
""
;
for
(
var
j=0;j<level+1;j++) level_padding +=
" "
;
if
(
typeof
(arr) ==
'object'
) {
for
(
var
item
in
arr) {
var
value = arr[item];
if
(
typeof
(value) ==
'object'
) {
dumped_text += level_padding +
"'"
+ item +
"' ...\n"
;
dumped_text += dump(value,level+1);
}
else
{
dumped_text += level_padding +
"'"
+ item +
"' => \""
+ value +
"\"\n"
;
}
}
}
else
{
dumped_text =
"===>"
+arr+
"<===("
+
typeof
(arr)+
")"
;
}
return
dumped_text;
}
</script>
</head>
<body>
<input type=
"text"
id=
"uid"
value=
"109023257393424023484"
/>
<input type=
"button"
onClick=
"getGplus()"
value=
"Get"
/>
<pre id=
"gplus"
></pre>
</body>
</html>