In my app a user grants my application extended permission and I get the access token and store it as its a long lived access token.
This user is shown a list of their friends and they select one.
I store their name and fbuid in my database.
Now on a day in the future I want to send a message to this friend’s wall.
Is this possible?
If not what other options are there to send a link to the friend in Facebook when the initial user is offline?
* Update
I was able to do this with the long lived access token and offline access as follows:
access_token = "AAACvmqy1nYoBAAZCk*************dZAMjsLxKxR7DaZBE0NxY8ZBGBW1q2mzsB9TDT0RvgeQcDdnyFJNAYRf0icnhlbikZD"
appID = '19307***********'
message = "Happy Birthday from your friends."
name = "Click here for your Birthday Surprise"
redirect_uri = URI.parse('http://localhost:3000/facebook/')
link = "https://www.facebook.com/dialog/oauth?client_id=#{appID}&redirect_uri=#{redirect_uri}"
caption = "Your friends have created a surprise for you. Click the link to see what it is."
picture = 'http://www.birthdaywall.net/logo-mail.png'
userID = '100002*********'
uri = URI.parse("https://graph.facebook.com/#{userID}/feed")
req = Net::HTTP::Post.new(uri.path)
result = req.set_form_data({:access_token => access_token , :message => message, :app_id => appID, :name => name, :link => link, :caption => caption, :picture => picture, })
sock = Net::HTTP.new(uri.host, 443)
sock.use_ssl = true
sock.start do |http|
response = http.request(req)
end
I don’t know if this is the best way but it works for me so I am using it. If anyone has a better way I would be very happy to know about it.
I guess you have the publish_stream permission already. You also need the offline_access extended permission to make your access token live long:
Enables your app to perform authorized requests on behalf of the user at any time. By default, most access tokens expire after a short time period to ensure applications only make requests on behalf of the user when they are actively using the application. This permission makes the access token returned by our OAuth endpoint long-lived.
See here: https://developers.facebook.com/docs/reference/api/permissions/