Wednesday, 15 January 2014

c# - How to open "Go to app" pop up on facebook page tab's checkbox click -



c# - How to open "Go to app" pop up on facebook page tab's checkbox click -

here facebook page

when user click on fitbook competition sec tab first forcefulness user page , allow utilize application. access app, first user needs allow appication app accessed user.

i doing coding in c#.net. here code.

testfb.aspx.cs code :

public partial class testfb : system.web.ui.page { private static string access_token = ""; protected string form_url = ""; public static string facebookid = ""; protected void page_load(object sender, eventargs e) { if (!ispostback) { getitemslist(); if (string.isnullorempty(convert.tostring(session["access_token"]))) { string app_id = "139295982898884"; string app_secret = "b5d2a88b56898610d54da2af498e3220"; string post_login_url = "http://dev.fitbook.com.asp1-23.ord1-1.websitetestlink.com/v4/fitbookcontest.aspx"; //string post_login_url = "http://localhost:4327/fitbookcontest.aspx"; string scope = "publish_stream,manage_pages"; string code = httpcontext.current.request["code"] ?? ""; if (code == "") { string dialog_url = "http://www.facebook.com/dialog/oauth?" + "client_id=" + app_id + "&redirect_uri=" + httpcontext.current.server.urlencode(post_login_url) + "&scope=publish_stream&display=popup"; httpcontext.current.response.redirect(dialog_url); response.write(dialog_url); } else { dictionary<string, string> tokens = new dictionary<string, string>(); string url = string.format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}", app_id, httpcontext.current.request.url.absoluteuri, scope, httpcontext.current.request["code"].tostring(), app_secret); httpwebrequest request = webrequest.create(url) httpwebrequest; using (httpwebresponse response = request.getresponse() httpwebresponse) { streamreader reader = new streamreader(response.getresponsestream()); string vals = reader.readtoend(); foreach (string token in vals.split('&')) { //meh.aspx?token1=steve&token2=jake&... tokens.add(token.substring(0, token.indexof("=")), token.substring(token.indexof("=") + 1, token.length - token.indexof("=") - 1)); } } access_token = tokens["access_token"]; session["access_token"] = access_token; getprofilepic(code); } //session["profileimage"] = imgprofilepicture; } } } private void getprofilepic(string code) { string accesstoken = convert.tostring(session["access_token"]); var app = new facebookclient(accesstoken); var me = (idictionary<string, object>)app.get("me"); testfb.facebookid = (string)me["id"]; string firstname = (string)me["first_name"]; string lastname = (string)me["last_name"]; string gender = (string)me["gender"]; //response.write(me); string url = "http://graph.facebook.com/" + testfb.facebookid + "/picture"; // response.write(url); //image imgprofilepicture = new image(); //imgprofilepicture = (image)httpcontext.current.session["profileimage"]; imgprofilepicture.imageurl = url; } }

it working fine localhost , server when accessing page directly. when integrating server path "facebook page tab", not open pop , showing blank white screen instead. here link page tab app . looking this

suggestions welcomed. help.

c# javascript facebook c#-4.0 facebook-c#-sdk

No comments:

Post a Comment