0

I am trying to do something like this. Lets say a user used FB Connect for registration in our site, so I can get the "uid" of facebook and I can store in DB. Now what I want each time that user will visit a store details page or item details page I will post that store/item image with link, photo, description etc to FB timeline.

Something like this:

$post_id = $facebook->api('/me/feed/', 'post', array(
'message' => $products_name, // item name
'link' => 'http://www.blabla.com/item/myshoes', // item url
'picture'  => $fb_img_src, // item image
'caption' => $products_name, // item name for caption
'description' => $products_description // item description
));     
} catch (FacebookApiException $e) {
$user = null;
}

This process works fine if user logged in to FB by using our FB app. But as I said I want to post if they not even logged in by using their facebook "uid".

Is it possible to authenticate that user depending on facebook "uid"?

Thanks in advance! Any clue/help will be appreciated!

  • 1
    you seriously want to post to facebook in the background whenever the user just visits a page? and you don´t see any problem with that? spam and stuff? ;) - luckily, this is not possible without approval from facebook, and you will never get the needed permissions approved for that. – andyrandy Sep 18 '14 at 10:01

1 Answers1

0

I strongly believe that posting anything to user's Facebook without their's consent or even their action will surely and quickly encourage them to leave your site forever. Do not do this.

Anyway - to answer your question:

Yes, it is possible to get access to user's Facebook and "do stuff", especially when a user is logged in both on Facebook and on your site. You just need to obtain user's access token (read about it in the docs), and make sure the users grants your app all aproppriate permissions. There are also access tokens that can be used offline (user is not even online), but I'm not going to discuss it here.

One way to obtains user's access token is to redirect the user to FB login url providing your APP_ID (as described in FB developers docs). FB will then redirect the user to your Fb-login URL with access code/access token, which enables you to do something like posting to users timeline.

Of course actions that you can take are limited according to permissions said user has granted for your app. And I have to remind you - it's a thin ice you're stepping on.

Kleskowy
  • 2,648
  • 1
  • 16
  • 19
  • If I give you my email id can you pls explain how can I do offline? Actually already I was able to do when user logged in to FB and our site but I wanted to know if it's possible to do when user not logged in to FB but if I have their FB user id. – Prosenjit Debnath Sep 19 '14 at 08:06
  • Do some research, I'm not going to give you the tutorial. Search through FB developers webpages and you'll probably figure it out somehow. https://developers.facebook.com/ – Kleskowy Sep 19 '14 at 08:14