hello,
i am using this snippet
in the website it works fine but in in MVC the same code gives error
{
"error": {
"message": "Missing client_id parameter.",
"type": "OAuthException",
"code": 101,
"fbtrace_id": "G+L45XHDJyK"
}
}
public class FacebookController : Controller
{
// GET: Facebook
public ActionResult Index()
{
FaceBookConnect.API_Key = "660793097769908";
FaceBookConnect.API_Secret = "8d4e10f2c337d4f649e38c5ddd5d1c6c";
ViewBag.Error = "Succcess";
@ViewBag.Fbuserid = "";
@ViewBag.FbUserName = "";
@ViewBag.FbName = "";
@ViewBag.FbImage = "";
if (Request.QueryString["error"] == "access_denied")
{
ViewBag.Error ="User has denied access.";
}
string code = Request.QueryString["code"];
if (!string.IsNullOrEmpty(code))
{
string data = FaceBookConnect.Fetch(code, "me?fields=id,name,email");
FaceBookUser faceBookUser = new JavaScriptSerializer().Deserialize<FaceBookUser>(data);
faceBookUser.PictureUrl = string.Format("https://graph.facebook.com/{0}/picture", faceBookUser.Id);
ViewBag.Fbuserid = faceBookUser.Id;
ViewBag.FbUserName = faceBookUser.UserName;
ViewBag.FbName = faceBookUser.Name;
ViewBag.FbImage = faceBookUser.PictureUrl;
}
return View();
}
public ActionResult facebookauth()
{
FaceBookConnect.Authorize("user_photos,email", Request.Url.AbsoluteUri.Split('?')[0]);
return View("Index");
}
public class FaceBookUser
{
public string Id { get; set; }
public string Name { get; set; }
public string UserName { get; set; }
public string PictureUrl { get; set; }
public string Email { get; set; }
}
}
button click evnt to call controller please advice
<a id="btn_add" href="@Url.Action("facebookauth", "Facebook", new { Id = ViewBag.Id })" class="btn red-bg white-c ">
Facebook
</a>