Topic-icon Offline posting

Active Subscriptions:

None
11 years 3 months ago #30023 by fb_73300008
Offline posting was created by fb_73300008
I would like to post updates to users Facebook walls even if they are not login is that possible?
The topic has been locked.
Active Subscriptions:

None
11 years 3 months ago #30024 by fb_73300008
Replied by fb_73300008 on topic Offline posting
Is there a way to change this code to allowing posting if the user is not login?

require_once JPATH_ROOT.DS.'components'.DS.'com_jfbconnect'.DS.'libraries'.DS.'facebook.php';
$jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
$post = 'is doing something';
$post = 'www.sourcecoast.com/jfbconnect';
if ($jfbcLibrary->getUserId()) // Check if there is a Facebook user logged in
$jfbcLibrary->setFacebookMessage($post);
The topic has been locked.
Support Specialist
11 years 3 months ago #30055 by alzander
Replied by alzander on topic Offline posting
You can post to a user's wall if they aren't logged in by slightly modifying that code you reference. However, I wouldn't really recommend it. Posting to a users wall is something that, according to Facebook's Terms of Service, should be something the user can approve the message that is being posted. Status messages are personal messages that the user should not be surprised to see posted on their behalf.

Depending on what you're trying to post, you may have a legitimate reason to do so. If it's promotional though, your messages will likely be marked as spam by a high percentage of your users which will, eventually, lead to your app being possibly evaluated or banned.

What Facebook recommends is using Open Graph Actions to post activities to a users Timeline. If you have a game, you can post that someone beat their top score (or something similar) using an Open Graph Action. Actions are events that are related to a user and are meant to be posted frequently and not always with user intent.

So, let me know if you still want to pursue that, and we can help you with the code to look up the user's access token and use it to post for the user when they are offline.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 3 months ago #30060 by fb_73300008
Replied by fb_73300008 on topic Offline posting
Ok yeah I understand each user will have to buy into the posting to their account. It's for a non profit organization that wish to post to their member Facebook page(who has approve offline posting).

The posting should be fine but if open graph is the approve solution I can go with that.
The topic has been locked.
Active Subscriptions:

None
11 years 3 months ago #30061 by fb_73300008
Replied by fb_73300008 on topic Offline posting
Also each message will be approved by the user. So I think the posting will be okay but I want to keep everything legal
The topic has been locked.
Support Specialist
11 years 3 months ago #30163 by alzander
Replied by alzander on topic Offline posting
Richard,
If you think you already have the approval of the user before the post is made, that's great. That's up to you on how to do that, and there are plenty of ways that can validly be done.

So, with that said, to post on behalf of a user, you can simply update the code above to look like:
require_once JPATH_ROOT.DS.'components'.DS.'com_jfbconnect'.DS.'libraries'.DS.'facebook.php'; 
$jfbcLibrary = JFBConnectFacebookLibrary::getInstance(); 
$post['message'] = 'is doing something'; 
$post['link'] = 'http://www.sourcecoast.com/jfbconnect'; 

// get the user's access token
$userMapModel = new JFBConnectModelUserMap();
$userMapModel->getData(1234); // 1234 is the ID of the Joomla user
$accessToken = $userMapModel->_data->access_token;
if ($accessToken != '' && $accessToken != null) // Don't post if no access_token found
{
   $post['access_token'] = $accessToken;
   $jfbcLibrary->setFacebookMessage($post);
}
The access_token will be valid for 2 months from the time the user last logged in, so you should be able to successfully post over that time.

Obviously test, a lot, and let us know how that goes!

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 3 months ago #30177 by fb_73300008
Replied by fb_73300008 on topic Offline posting
Thanks Sir!
The topic has been locked.
Support Specialist
11 years 3 months ago #30183 by alzander
Replied by alzander on topic Offline posting
No problem. Please let me know how that goes, but hopefully, it should work without any issues!

One thing I forgot to mention.. in the Facebook API tab of the Configuration area, you may want to add "publish_stream" to the Permissions to Request box. That will make sure the user is asked to grant the permission to post to their feed when they login to your site.

Thanks,
Alex
The topic has been locked.