I have a snippet where I allow a user on my MVC Asp.net Site to publish a POST. It works fine.
What I need is when the POST is published and a facebook user clicks on it (There is a url action that takes you to mywebsite if the user clicks on it) . How would I get the userId or something indicating it was clicked by XXXX facebook user?
Once a user on my site publishes this post, a friend may click on the link and I want to know what user clicked on it.
function facebookShare()
{
FB.ui({
method: 'feed',
name: "My gallery - Price: $49.99",
link: "https://mygallery.net/Product/Details/99",
picture: "http://mygallery.com//Images/Products/image.jpg",
description: "In the last 100 years of....",
caption: "Product Name: Awesome Pix-X",
quote:"Quote: You will always be mine!"
},
function (response)
{
if (response && !response.error_message) {
alert('post_id : ' + response.post_id);
} else {
alert('Error while posting.');
}
});
}
So Do I add a query parameter in here to dynamically get facebook user who clicks on it?
link: "https://mygallery.net/Product/Details/99",
If the user did not authorize your App, there is no way to know. If he authorized your App, you can get his id with FB.getLoginStatus, for example.
Related
I am using a Facebook social plugin share button, I want to capture the event whether the user shares the event or not.
Is there a way to check whether the user shared it or not using plugin only?
Using the FB.ui method provided by the Facebook JavaScript SDK, you can pass a callback as the second argument and check for the post_id on the response object.
FB.ui({
method: 'feed',
link: 'http://www.example.org/',
picture: 'http://placehold.it/400x400',
caption: 'Title',
description: 'Some description...'
}, function (response) {
if (response.post_id) {
// This post was shared
} else {
// This post was not shared
}
});
More information can be found in the Facebook share documentation.
hi i am using share on facebook using javascript.
When i login to my app for the first time and on facebook from this code for the first time the it works perfect.I am able to share multiple times.
problem starts from here
If i logout from the app and again login then if i click on share button it does not opens popup.
Check my code and correct me if i am wrong somewhere.
Below is my code.
function share(){
var share = {
method: 'feed',
name: 'Real Prize Arcade',
link: 'http://india-webdev.com/arcade/www/RPA.mp4',
picture: 'http://india-webdev.com/arcade/www/images/arcade.png',
description: 'Real Prize Arcade',
source: 'https://www.youtube.com/v/1CE6W5BubQo'
};
FB.ui(share, function(response) {
if(response && response.post_id !== undefined) {
alert('Successfully Shared');
}
});
}
I'm making a invitation system to a project that I'm currently working on. The invitation system allow users to invite a limited number of their Facebook friends to use my project. Let's assume users may have only 20 invitations.
Facebook have a option called max_recipients that limit the number of invitations a user can do. This option is working fine for invitations <= 5, but this is not working for invitations > 5.
In the end of the question you can find my code.
Here limiting invitations in 5:
Here limiting invitations in 20:
Following you can check my code:
window.fbAsyncInit = function() {
FB.init({
appId: "foobarfoobarfoobar",
cookies: true,
xfbml: true
});
}
function FacebookInviteFriends() {
FB.ui({
'method': 'apprequests',
'message': 'A hidden foobar description.',
'max_recipients': '5', // if changed to '20', this stop working.
'title': 'FooBar'
// Callback (insert the invites in database)
}, function(response) {
// If user selected at least one user
if (response.length != 0) {
$.post('<%= invites_path %>', {
request_id: response.request,
to_ids: response.to
}, function(data) {
$('#remaining-invites').text(data);
});
}
});
}
$('#invite').click(function(event) {
fbAsyncInit(); // just for didatic purposes
FacebookInviteFriends();
});
I'm following these two Facebook docs: here and here.
Am I doing something wrong? How I can solve that?
I got a final answer from Facebook:
"Hi Fernando, as it turns out the behavior to hide the counter for max_recipients > 5 was a deliberate product decision, so I am closing this as by design. I am unable to revert your report from confidential to public. Thanks for your patience." (Dave Dosanjh, Facebook Team).
Because I cannot do anything about that and Facebook also don't will make anything about that, I'm answering and giving the best answer to this answer. There's nothing to do, guys :(.
I have a site with a working Facebook login.
The problem is happens when the user comes to the site for the first time (or after clearing cookies).
The user flow is the following:
User clicks "Sign Up with Facebook"
User is redirected to Facebook authentication
If User accepts, he/she is redirected to the 'Sign Up' page.
The problem is that if the person is doing this for the first time, they are always redirected back to the home page.
There are only 2 possible views that can be given for this url
The Sign Up page, with only some form data sent as parameters
An alert box upon successful DB persistence
Thus, I have ruled out PHP as a possible cause of the redirect.
I have included the JavaScript managing the Facebook interaction.
All other relevant code can be found in the HTML of the page.
The Page can be found at http://trioisrael.com
function fb_login(){
FB.login(function(response) {
if (response.authResponse) {
window.location = "http://trioisrael.com/signup"
//console.log(response); // dump complete info
access_token = response.authResponse.accessToken; //get access token
user_id = response.authResponse.userID; //get FB UID
FB.api('/me', function(response) {
user_email = response.email; //get user email
// you can store this data into your database
});
} else {
//user hit cancel button
alert('We use facebook to make sure that everyone is really who they say they are');
}
}, {
scope: 'user_photos,user_birthday'
});
}
Trying to do additional stuff after assigning a new value to window.location (which should be window.location.href, of course) does not make sense.
If you want to do additional stuff after login, do it before redirecting the user somewhere else.
I want to add a custom Facebook share button to my website like the ones you see at the top of BBC news stories, like http://www.bbc.co.uk/news/uk-19535236. They're using the Facebook Feed Dialog for this. So when you click on the link you get a dialog that allows you to post the URL of whatever page you're on to your timeline.
The FB.ui method seems the best way of invoking the dialog, because it automatically creates the right type of popup for your device. So people using mobiles'll see a popup that suits their devices. This method also allows us to specify a callback, so once the user's shared a link we can augment the share count on the page they're sharing.
I'm trying to follow the first example on http://developers.facebook.com/docs/reference/dialogs/feed/.
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p><a href="#" onclick='postToFeed(); return false;'>Post to Feed</a></p>
<p id='msg'></p>
<script>
FB.init({appId: "00000000000", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'http://example.com/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
FB.ui(obj, callback);
}
</script>
(subsituting my actual app_id for 00000000000 and site URL for http://example.com/). But I get this error when I click on the link:
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.
I get this even when the 'link' parameter exactly matches the 'Site URL' for the app in my Facebook app settings.
Can anyone tell me how I can get this to work? I want people to be able to share any page on my site, not just a URL corresponding to my Facebook app.
For sharing to work, minimum requirement in application configuration is to set atleast
App Domains ( under Basic Info )
Site URL ( under Website with Facebook Login )
i.e.
App Domains : example.com
Site URL : http://example.com
setting other parameters can also work like Mobile Site URL etc.