Javascript可以获得文本功能吗?我想的是eval()的反转.
function derp() { a(); b(); c(); }
alert(derp.asString());
Run Code Online (Sandbox Code Playgroud)
结果将类似于"a(); b(); c();"
它存在吗?
我正在尝试制作Facebook应用程序,但我无法在画布内的重定向方案中获得授权.
使用javascript api,我在弹出方案中很容易地使用它:
$("#loginButton").click(function(e) {
FB.login(function(response) {
if (response.perms) {
perms();
}
}, {perms : 'publish_stream'});
Run Code Online (Sandbox Code Playgroud)
但弹出窗口应该是一个不必要的额外点击,因为我看到的每个其他应用程序在向您显示登录页面之前都会请求授权.像这样:
我认为他们只是使用重定向方案.所以我花了一整天时间尝试了不同的方法:
header("Location: https://graph.facebook.com/oauth/authorize?client_id=" . $gAppId . "&redirect_uri=" . urlencode($gUrl) . "&perms=publish_stream");
header("Location: http://www.facebook.com/login.php?v=1.0&api_key=" . $gApiKey . "&next=" . urlencode($gUrl) . "&canvas=");
header("Location: http://www.facebook.com/connect/uiserver.php?app_id=" . $gAppId . "&next=" . urlencode($gUrl) . "&return_session=0&fbconnect=0&canvas=1&legacy_return=1&method=permissions.request");
Run Code Online (Sandbox Code Playgroud)
但所有这些,而不是显示授权请求的东西,显示如下链接:
非常有趣的是,如果我在新标签中打开iframe的地址,我会得到我想要的授权请求.但我想让它立即显示,而不是像其他应用程序那样额外点击.
以下是一个应用程序的示例,该应用程序在重定向表单中一次性执行授权和请求权限,甚至在显示登录页面之前:
www.facebook.com/send.fortune.cookies
他们是怎么做到的?