我有一個應用程序將用於Facebook頁面標籤中,我將要求它提供基本權限。C#Facebook SDK授權流程 - 如何重定向回頁面?
我在ASP.NET 3.5中使用ASP.NET MVC2。
我用下面的action屬性:
[HttpPost]
[CanvasAuthorize]
public ActionResult Index(string signed_request)
{
ViewData["section"] = "post";
FacebookPageModel page = new FacebookPageModel();
if (!string.IsNullOrEmpty(signed_request))
{
string signedRequest = Request.Form["signed_request"];
var DecodedSignedRequest =
FacebookSignedRequest.Parse(
((FacebookConfigurationSection)
ConfigurationManager
.GetSection("facebookSettings"))
.AppSecret,
signed_request);
var SignedRequestData = DecodedSignedRequest.Data;
var RawRequestData = (IDictionary<string, object>)SignedRequestData;
// ok, start getting the data
page.user_id = FacebookWebContext.Current.UserId.ToString();
if (RawRequestData.ContainsKey("page") == true)
{
Facebook.JsonObject RawPageData =
(Facebook.JsonObject)RawRequestData["page"];
if (RawPageData.ContainsKey("liked") == true)
{
page.UserLikesThisPage = (bool)RawPageData["liked"];
}
}
if (RawRequestData.ContainsKey("app_data") == true)
{
page.app_data = RawRequestData["app_data"].ToString();
}
}
return View(page);
}
public class FacebookPageModel
{
public Dictionary<string, string> SignedRequestParameters { get; set; }
public bool UserLikesThisPage { get; set; }
public string app_data { get; set; }
public string user_id { get; set; }
public IEnumerable<TwitterSearchResultsModel> tweets { get; set; }
}
的web.config:
<facebookSettings
appId="221731264504206"
appSecret="blah-blah-blah"
canvasUrl="http://url-of-canvas-page-tab/"
canvasPage="http://url-of-canvas-page-tab/" />
調用CanvasAuthorize沒有任何其他參數似乎要求基本權限,這就是我想要的。問題在於,點擊允許後,轉發網址會將我發送到用戶的個人資料頁面,而不是我的頁面標籤。
如何在允許請求的權限後將我的應用程序配置爲將用戶轉發回調用頁面?
感謝, 斯科特
是否有另一種方法來測試一個人是否授權您的Facebook頁面選項卡? – Scott 2011-05-25 21:52:30