how to request additional scopes from facebook api - facebook

I redirect users to the URL
display = '&display=page',
state = '&state=facebook_auth_' + csrfToken,
scope = '&scope=' + this.scopes,
redirect = '&redirect_uri=' + redirectUrl,
facebookURL = 'https://graph.facebook.com/oauth/authorize?client_id=' + this.clientId + redirect + scope + display + state;
For some reason, when I try to request new permissions by redirecting users to the URL above, Facebook does not show a prompt asking the user for access to the new permissions. What am I doing wrong

Related

How to redirect in JAX-RS after a post to a get

I'm developing a simple login form (security is not a problem) where the user visits the page login inserts username and password and press send that POST these information to the page check.
Page check checks credential and, if everything is OK, creates cookie and redirect to page home, otherwise redirects to page login.
I use the following redirect:
return Response.temporaryRedirect(new URI("/home")).cookie(cookie, cookie2).build();
This redirects from check (#POST method) to home (#POST method), I just wanna to redirect to home (#GET method).
Important note: I'm a newbie of JAX and what I would like to create is a RESTful service. Are redirects a correct way to implement a REST service?
Now I'll show you small slices of code hoping:
check Page
#POST
#Produces(MediaType.TEXT_HTML)
public Response checkLogin(#FormParam(Login.fieldUsername) String user, #FormParam(Login.fieldPsw) String psw) throws URISyntaxException {
boolean val = db.checkLogin(user, psw);
NewCookie cookie;
NewCookie cookie2;
if(val){
//Valid access + cookie creation
cookie = new NewCookie("username", user);
cookie2 = new NewCookie("hashedPassword", psw);
return Response.temporaryRedirect(new URI("/home")).cookie(cookie, cookie2).build();
} else {
//Wrong login + cookie deletion
cookie = new NewCookie("username", "");
cookie2 = new NewCookie("hashedPassword", "");
return Response.temporaryRedirect(new URI("/login")).cookie(cookie, cookie2).build();
}
}
login page
#GET
#Produces(MediaType.TEXT_HTML)
public Response showLoginForm() throws URISyntaxException{
boolean validCookie = db.checkLogin(username, hashedPassword);
String data = "<form name='Username' action='"+ redirect +"' method='post'><ul>"
+ "<li><label for='"+fieldUsername+"'>Username</label>"
+ " <input type='text' name='"+fieldUsername+"' placeholder='Insert username' required></li>"
+ "<li><label for='"+fieldPsw+"'>Password</label>"
+ " <input type='password' name='"+fieldPsw+"' placeholder='Insert password' required></li>"
+ "<li><input type='submit' value='Login'>"
+ "</li></ul></form>";
if(validCookie){
return Response.temporaryRedirect(new URI(homepage)).build();
}
else {
return Response.ok( showTheForm(data) ).build();
}
}
You can use:
Response.seeOther(redirecttUri).build();

I am using action_send for Facebook sharing here insert image only but not added text what is the reason?

Here is Facebook sharing code:
String text = "Offer Ends:" + offerending + "\n Offer Type:"
+ offertype + "\n Address:" + offaddress + "\n"
+ webbsuitee;
String completePath = Environment.getExternalStorageDirectory()
+ "/" + "temporary_file.jpg";
File file = new File(completePath);
// Uri imageUri = Uri.fromFile(file);
Uri imageUri = Uri.fromFile(file);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello");
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "send"));
It is closed by Facebook API. You need to use the Facebook SDK for Android to do so!
check this: https://developers.facebook.com/bugs/332619626816423

Facebook app permission request before using my app [duplicate]

I have a facebook app installed and working great.
What I would like to do is add in the functionality of requesting user permission data.
such as - read_friendlists,user_groups,email,user_birthday,status_update,publish_stream,
Firstly here is the code that checks if a fan or none fan is on our facebook timeline app.
// If a fan is on your page
if ($like_status) {
$a = file_get_contents("http://www.domain.com/home.php");
echo ($a);
}
else {
// If a non-fan is on your page
$a = file_get_contents("http://www.domain.com/home.php");
echo ($a);
}
What I would like to do, is, if a none fan is on our page, open a facebook request for permission and set a number of permissions. Then redirect them to the // if a fan is on our page.
I have had a good look around here but I am still not clear how to setup the "request" for permission page.
Any help would be greatly appreciated
you can do this in two ways..
1) Open oauth dialog in page by setting the url
var oauth_url = 'https://www.facebook.com/dialog/oauth/';
oauth_url += '?scope=email,user_birthday,user_location,user_about_me,user_likes';
oauth_url += '&client_id=' + appid;
oauth_url += '&redirect_uri=' + encodeURIComponent('https://www.facebook.com/pages/' + appname + '/' + pageId + '/?sk=app_' + appid);
window.top.location = oauth_url;
2) Or you can open the oauth dialog in popup:
FB.login(function(loginResponse) {
if (loginResponse.authResponse) {
var userId = loginResponse.authResponse.userID;
}
else {
//'User cancelled login or did not fully authorize.
}
}, { scope: 'email,user_birthday,user_location' });

Login repeats after authenticate, if i try to send a friends request

Im trying to build a 'cheer action' for my app. It is a game in iPhone, so I want to post a 'welcome message' in the users wall (I will need 'public_stream' permission) and then invite his friends to visit my webpage.
Here my question.. I authenticate the user using:
_url = "http://www.facebook.com/dialog/oauth/?client_id=" + app_id + "&redirect_uri=" + app_net_folder + auth_response_uri + "&state=" + session_id;
I get response in my uri, and then I get the access_token, user_id, etc.
Then I post a message in his wall in this way:
_url = "https://www.facebook.com/dialog/apprequests?app_id=" + app_id;
_url += "&message=" + string_ToUrl(String_ToHTML(request_msg));
Now I want to invite his friends (using a multi friend list dialog). To do it, I can only use JavaScript FB.ui. In this way:
FB.init({appId : app_id, logging : false, frictionlessRequests: true, oauth : true});
FB.ui({method: 'apprequests', message: msg, title: title}, requestCallback);
When I do it, a window is opened asking me again for the user's login.. but my user has been already authenthicated. So I dont know how to say to FB in JavaScript that my user has been alredy authenthicated! (I even have the access_token, but I don't know how to use it in JavaScript functions).
Someone knows what am I doing wrong? or how to do those two actions asking just one time for the user's login?
Thanks!!
if you are already log in, you can get login user id using below code
var userId = FB.Facebook.apiClient.get_session().uid;
if(userId > 0 || userId != '')
{
alert('user is already log in');
}
hope it's helpful to you

multi-friend selector does not work in https (secure browsing enabled)

We are using facebook iframe app in https mode, from our app we need to send an invitation to multiple friends using multi-friend selector.
But when we click on Select Friends button, it is showing blank popup. It works fine for http (non secure browsing).
"<fb:serverfbml><script type=\"text/fbml\">" +
"<fb:fbml>" +
"<fb:request-form action=\"" + (HttpContext.Current.Request.IsSecureConnection ? ConfigurationManager.AppSettings["Callback"].Replace("http://", "https://") : ConfigurationManager.AppSettings["Callback"]) + "pagename.aspx?dbskip=true&fb_sig_user=" + fbuserid + "\"" +
"method=\"POST\"" +
"invite=\"true\"" +
"type=\"My App \"" +
"content=\"" + "my content" +
"<fb:req-choice url='" + "my choice"+ "'" +
"label='" + " my text "+ "'/>" +
"\">" +
"<fb:multi-friend-selector bypass=\"cancel\" email_invite=\"false\" max=\"35\" cols=\"5\" actiontext=\"Select friends to send invitation\" rows=\"3\"/>" +
"</fb:request-form></fb:fbml></script></fb:serverfbml>";
Thank in advance......
Maybe you shouldn't use legacy FBML now. It is deprecated.