Facebook-login issue - facebook

This is our link for the fb or old way sign-in: http://www.greeceinsiders.com/login
Does the fb-login work to you? When I click it it redirects me to the same page.
Sometimes it works sometimes not. When a user logs in with fb we collect his vredentials sucha as email,city, name in our mysql database. Does anybody had the same problem? Is there any good tutorial out there, that explains it step by step and is for the current fb api?
Any suggestions or feedback is welcome, thank you! Some code
FOUND IT!

I like to use the FB.login method. This allows me to set the permissions that I want (such as email) and access the info on my server through a Facebook library like https://github.com/facebook/php-sdk. There are also good tutorials on https://developers.facebook.com/docs/authentication/:
FB.login(
function(response) {
if (response.authResponse) {
$.ajax({
url: Global.base_url + 'user/facebook_log_in/',
dataType: 'json',
success: function(data) {}
});
}
else {
// Display facebook error
}
},
{
scope: 'email'
});

Related

FB.ui not returing post id in response

I am following this thread Is it possible to add a link to download a file that can only be downloaded by sharing it on Facebook? to detect if user share my given link or not, If user share then allow him to access the next level.
This is how i am doing:
FB.ui({
display: 'popup',
method: 'share',
href: 'url-here',
} , function(response){
console.log(response.e2e)
if (response && response) {
$.ajax({
url: ajaxurl,
type: 'post',
data: {action: 'unlock_om_gmap'},
success: function(res) {
}
});
}
});
But everytime its returning Object { e2e="{"submit_0":1406412308276}"} not any post id. Is there anyone familiar with this issue? How do i check if user shared my link or not?
As I mentioned in the comments, as per the Facebook docs on this topic, you'll need to check for an object_id property in the response data to determine if an Open Graph story was shared, but this is only available if the user is logged into your app using Facebook and has granted publish_actions

Angular + Facebook JS SDK login: Not requesting my permissions

FB.login() is not working. The FB Popup is not requesting the right permissions. I can clearly see, in the source code that there's a fn handler that uses the right parameters / parameters being set correctly. I'd like to understand why isn't this working ?
This is the code I've got so far:
http://jsbin.com/IteY/1/
This is where I'm setting the permissions list:
facebook.login(function(response) {
console.log(response);
}, {scope: 'email,user_likes'});
in accordance with the docs ( https://developers.facebook.com/docs/reference/javascript/FB.login/ )
by doing console.log in the fn handler for login(), I get the fn function(response){ ... } and the {scope: 'email,user_likes'}
I found some other users reporting the same issue using the FB SDK here in SO. I tried the tip to use "perms" instead of "scope", but I get:
OAuth2 specification states that 'perms' should now be called 'scope'. Please update.
Not appearing to be the problem. This also shows that the param is being send there. Go wonder why's not working ?! I've cleaned cache too
Originally I've reported this issue (AngularJS: DI Error - No module: $facebook, why isn't working?) that was solved. Now having access to the FB object I'm not able to get the right permissions from the user. I'm sure that this is an issue related with Facebook API and not the Angular module
**** I've also tried to check the permissions by using .api like :
facebook.api('/me/permissions', function (response) {
console.log(response);
} );
console.log reports:
Object {error: Object}
***** Now I've tried to access through the graph using the access_token:
https://graph.facebook.com/me/permissions?access_token=XXXXXXXX
and I can see the right permissions, but the Facebook login popup never asked me about them ? Shouldn't it ?
{
"data": [
{
"installed": 1,
"basic_info": 1,
"email": 1,
"read_friendlists": 1,
"user_likes": 1,
"user_online_presence": 1,
"user_friends": 1
}
],
"paging": {
"next": "xxxxxxx"
}
}
I've now asked a different user, who I've added to my sandbox as an admin and he got the required permissions popup! So, I think is something to do, with my own username who had this permissions already set or something - even though I tried to delete the cache, etc!
So, there's no issue to solve. Hope this is useful for someone else in the future!
Any one experienced can take a look ?
Thank you
Try attaching a listener to the facebook login event / statuschange:
$facebookProvider.Event.subscribe('auth.authResponseChange', function (response) {
console.log(response);
})
And look at the response element to see if you have an error or not

log on to facebook through extension

I've already registered my app on Facebook developer and got an ID, but had hard time to characterize the my app(chrome extension), it's website app, mobile app, facebook app? What I wanna do is a simple extension that allows users simply to click on it, and the background JavaScript calls the Facebook API to ask the users to log in like this.
window.fbAsyncInit = function() {
FB.init({
appId : '123456789',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
};
chrome.browserAction.onClicked.addListener(function(tab) {
FB.login(function(response) {
if(response.authResponse) {
alert('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
} else {
alert('User cancelled login or did not fully authorize.');
}
});
});
However, it pops up a window that says an error occurred, it is another way of saying "I am not authorized", how do I specify my app's URL on the Facebook developer page, because the extension's URL is a garbage like this chrome extension://asdjlajsldj/ or anyone knows any workaround? Thank you
I would assume that Facebook's API uses OAuth 2 to let applications access users data. Google provides a way of doing this with an example in their API section. I have also have posted an alternative method on GitHub. Note that my method will require some alternations to fit Facebook's interface but the idea is the same (I have a GitHub branch to do this with GitHub).
Essentially your extension must get an access token for the user from Facebook, then using this token as a parameter you can query private data from the API. What makes it seem difficult is the fact the the chrome extensions are sandboxed and have no return URL, but using one of the two methods above should do you just fine.
Good Luck!

Uploading Image With Facebook JS SDK

I've put together a script, with the help of another SA post, but the issue I'm having is it's always returning error. When logging the error with console log it contains no properties so I can't determine why I am getting the error.
$(".add-image").click(function() {
FB.login(function(response) {
if (response.authResponse) {
var imgURL="http://farm4.staticflickr.com/3332/3451193407_b7f047f4b4_o.jpg";
FB.api('/album_id/photos', 'post', {
message:'Test',
url:imgURL
}, function(response){
if (!response || response.error) {
console.log(response);
} else {
alert('Post ID: ' + response.id);
}
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'publish_stream'});
});
I've created the app. Added the API ID when including the Javascript.
When running I get a pop up asking me to log in, and it seems to log me in without problems. But it returns an error when checking for a response or response.error.
Any advice.
Not sure if this is still a problem for you, but I've been looking into the same thing recently and I believe that, for this type of upload, FB basically requires source to be the image data itself, not a URL to the image. (See the create photos section on https://developers.facebook.com/docs/reference/api/album/ - it indicates that the source paramater must be multipart/form-data.)
So you have a few workarounds:
1) You may be able to do it from JS if you can create a custom Open Graph Object. I haven't tried this yet, but https://developers.facebook.com/docs/opengraph/usergeneratedphotos/ looks like it expects a URL rather than the post data itself.
2) If the image is originating on the user's computer, you can create an HTML form that submits to FB and have the image go directly from the user to FB without ever hitting your server. This blog post shows an example of that: https://developers.facebook.com/blog/post/498/
3) If the image is originating in your system, you can do a POST from your server to FB that mimics the above form. If it's somewhere else online (such as Flickr), you can download it to your system first and then POST it to FB. You'll have to include an access_token in the request. I don't know what language / framework you're using on your server, but there's probably a library to make creating POST requests easier.

Hide content from non-fans in a Facebook *IFrame* (Not FBML)

it is incredibly easy to hide content from someone who does not like your application...if you're using FBML. I'm using an iFrame and the JavaScript SDK, and am having terrible difficulty figuring this out.
The behavior I'm seeing (both logged in and out) is that does not seem to be supported by FB.XFBML.parse(). Am I mistaken or is there an alternative method I can use that does not require the user to give explicit permission?
Finally figured it out!
After you have initialized the api (using FB.init()) simply do the following:
FB.api('/mypage', function (response) {
FB.api({ method: 'pages.isFan', page_id: response.id },
function (response) {
alert(response);
});
});
When the '/mypage' response comes back, it has the page id of the profile. Use that in the pages.isFan call and it will return a boolean object telling you if the current user has Liked that page or not.
No need to deal with authentication, extended permissions, or any FQL.