アイデア:ASP.netを使用してJavascriptを呼び出すPHPをシミュレートしようとしています
$Dialog='https://www.facebook.com/dialog/oauth?client_id='.$Key.'&redirect_uri='.urlencode($Done);
echo'<script>top.location.href = "'.$Dialog.'";</script>';
サーバー側の流れ:
using System;
using System . Collections . Generic;
using System . Linq;
using System . Web;
using System . Web . UI;
using System . Web . UI . WebControls;
using System . Text;
using System . Security . Cryptography;
using System . Collections . Specialized;
namespace Facebook
{
public partial class Default : System . Web . UI . Page
{
string Key = "397010480372609";
string Value = "***************";
string Permissions = "email,publish_actions,user_games_activity,friends_games_activity,publish_stream";
string Done = "https://localhost:10010/Done.html";
string Facebook = "https://www.facebook.com/";
string Dialog = "dialog/oauth";
protected void Page_Load ( object sender , EventArgs e )
{
Response . Redirect ( Facebook + Dialog + Query ( new NameValueCollection ( ) {
{ "client_id" , Key },
{ "redirect_uri" , Done }
//{ "scope" , Permissions },
//{ "state" , "" },
//{ "response_type" , "code" }
//{ "display" , "" }
} ) );
}
private string Query ( NameValueCollection Collection )
{
return "?" + string . Join ( "&" , Array . ConvertAll ( Collection . AllKeys , Key => string . Format ( "{0}={1}" , HttpUtility . UrlEncode ( Key ) , HttpUtility . UrlEncode ( Collection [ Key ] ) ) ) );
}
}
}
Done.html :
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Done</title>
</head>
<body>
<h1>Hello World!
</h1>
</body>
</html>
ログ:
[12:26:04.454] POST https://apps.facebook.com/ajax/apps/usage_update.php?__s=1 [HTTP/1.1 200 OK 257ms]
[12:26:04.769] GET https://apps.facebook.com/_silverlight/ [HTTP/1.1 200 OK 1029ms]
[12:26:05.314] POST https://localhost:10010/ [HTTP/1.1 302 Found 3ms]
---> [12:26:05.383] GET https://www.facebook.com/dialog/oauth?client_id=397010480372609&redirect_uri=https%3a%2f%2flocalhost%3a10010%2fDone.html [HTTP/1.1 200 OK 501ms]
[12:26:05.677] GET https://apps.facebook.com/ai.php?ego=AT76ukhNGbYVnWIi7k_pBVSIqDPGVWMXGApNCp_ZP6E8Gr5I2sqK0UfQI7fZnW0YKD70p1B5odpyaBePTI4rmSnhnyR3mI2WdPsZPQ43jeegdD77MOL7ROQBJWIftJ3Em9vA3peI1CW4eJ8r7WA7KSxNEjEy2Z-AGK4Y31Ac0Qg8ERh_WLoBDkRcFo3uyE8E44HG42oNPMa2BQqxO8yn9yJOsBZylTbERMxw9nasN2DV99XiUmOFY7pVmTO2uJSkWneY-40hE_utKSGh7c-w-Rv4w9ILvvJuvqzJDUapIb19Yg67gI0v4uOyS8vNarQiP_2BvSIduuIduI6orjne8ERRRpBkqMtY1kd-YTm-EF2RzLy_iZsZgYKEn92BBrPTmfu1R2KoJYmrlD0qpdLMf34D1N0IY2oIBNG1kYXB-S5TY09mY_Rs9qCQNYDX3vLKjCtJ3vm7sNGejhSv [HTTP/1.1 200 OK 267ms]
[12:26:06.371] GET https://www.facebook.com/sound_iframe.php [HTTP/1.1 200 OK 313ms]
問題 : ASP.net リダイレクトが実際には機能していません。