ASP.Net MVC 4 Facebook テンプレートと「フレームワーク」を試していますが、「Birthday app」サンプルを除いて、インターネットで助けを得るのが難しいと感じています。
「いいねゲート」を備えた単純な Facebook アプリケーションを作成しています。つまり、特定のページに「いいね」した場合にのみアプリにアクセスできるようにする必要があります。
私の考えは、ユーザーがファンページに「いいね」したかどうかをコントローラーでチェックインし、そうでない場合は「LikeFirst」ビューにリダイレクトすることです。
テンプレートから直接取得したコントローラーは次のとおりです。
[FacebookAuthorize("email", "user_photos")]
public async Task<ActionResult> Index(FacebookContext context)
{
if (ModelState.IsValid)
{
var user = await context.Client.GetCurrentUserAsync<MyAppUser>();
if(//how check the user has liked the fan page)
{
return View(user);
}
else
{
return View("LikeFirst");
}
}
return View("Error");
}
サンプルで得たものから、フレームワークは実際に "MyAppUser" オブジェクトを使用して Facebook クエリを作成します。
これは、サンプル アプリで使用される型です。
public class MyAppUser
{
public string Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
[JsonProperty("picture")] // This renames the property to picture.
[FacebookFieldModifier("type(large)")] // This sets the picture size to large.
public FacebookConnection<FacebookPicture> ProfilePicture { get; set; }
[FacebookFieldModifier("limit(8)")] // This sets the size of the friend list to 8, remove it to get all friends.
public FacebookGroupConnection<MyAppUserFriendSimple> Friends { get; set; }
[FacebookFieldModifier("limit(16)")] // This sets the size of the photo list to 16, remove it to get all photos.
public FacebookGroupConnection<FacebookPhoto> Photos { get; set; }
}
Facebook のドキュメントから、/PROFILE_ID/likes/PAGE_ID に対して HTTP GET を実行するだけでそれを確認できるはずですが、ASP.Net MVC Facebook フレームワークを使用してそれを行うにはどうすればよいですか? MyAppUser クラスで変更できるものはありますか? 全然違うものですか?
ありがとう!