I needed this module to work with the newest Facebook PHP SDK (v5) so it can update posts and just wanted to share the results.
The module supports updating the posts now, although the message field is the only field which actually updates.
The documentation is a little unclear on this: Graph API Reference says "all fields in the publishing Section" -> https://developers.facebook.com/docs/graph-api/reference/v2.5/post but through the UI it is not possible to update the link and name fields -> https://www.facebook.com/help/201770183198968.

So here are the quick specs:

- PHP 5.4 or higher (because of Facebook SDK)
- Facebook SDK v5 (in libraries/facebook-php-sdk-v4)
- Graph API 2.5 (is hardcoded in FBAutopost.php)

Oh and I dropped support for the SDK v3.

You will need to update your "update in fb" and "delete in fb" rules, because "delete in fb" needs a page id argument now and "update in fb" now has the correct page ids (array_merge lost the ids before in fb_autopost_entity_rules.inc)

It seems to be working for me now but no guarantee that it will work for you.
Please feel free to test, comment and contribute

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heng created an issue. See original summary.

mskill99’s picture

Heng, thanks for doing this. The patch did not work for me. (Failed on Git apply) I tried it on 7.x-1.4. Did you use 7.x-1.x-dev by chance? I'd really like to get this working if you have any guidance...

KevinVb’s picture

I have tried the patch and this is the output

patching file class/FBAutopost.php
patching file class/FBAutopostPost.php
patching file fb_autopost.admin.inc
patching file fb_autopost.drush.inc
patching file fb_autopost.info
Hunk #2 FAILED at 15.
1 out of 2 hunks FAILED -- saving rejects to file fb_autopost.info.rej
patching file fb_autopost.install
patching file fb_autopost.module
patching file fb_autopost.theme.inc
patching file fb_autopost_entity/class/FBAutopostEntity.php
patching file fb_autopost_entity/class/FBAutopostEntityEvent.php
patching file fb_autopost_entity/class/FBAutopostEntityPost.php
patching file fb_autopost_entity/fb_autopost_entity.info
Hunk #1 FAILED at 12.
1 out of 1 hunk FAILED -- saving rejects to file fb_autopost_entity/fb_autopost_entity.info.rej
patching file fb_autopost_entity/fb_autopost_entity.rules.inc
patching file fb_autopost_types/fb_autopost_types.info
Hunk #1 FAILED at 122.
1 out of 1 hunk FAILED -- saving rejects to file fb_autopost_types/fb_autopost_types.info.rej
patching file fb_permissions/fb_permissions.module

There are some issues with changes done to the .info file.
I'm currently trying to set things up, SDK is working:
Facebook PHP SDK 5.0.0 - Support for this version is experimental

I'm using:
- FB autopost dev version
- FB api v 2.5
- SDK v 4.5.0

topdillon’s picture

Did you ever get this working?
Which SDK?

xadag’s picture

I applied this patch well (except reject on .info but not important) on the latest dev version of the module (4 april), with the latest sdk from facebook
https://github.com/facebook/facebook-php-sdk-v4

GuyPaddock’s picture

This patch applies cleanly if you checkout the latest code from dev using GIT rather than downloading the dev release from Drupal.org. The reason for this is because the Drupal.org packaging system adds extra version information and timestamps to the .info file.

The other comments in this issue seem to imply that the patch is improper because of the conflicts on the info files. Quite the opposite -- the patch was created from the copy of the code in GIT, per Drupal's standard documentation.

Having said that, the patch is not named correctly. See the docs on this.

GuyPaddock’s picture

Status: Active » Needs review
FileSize
26.15 KB

The original patch had three issues:

  • Lots of commented out code for deprecated functionality / logic that was written for the patch and then not used
  • Lots of trailing whitespace, increasing the chances for merge conflicts
  • Incomplete implementation of hook_requirements (looks like this came from the same bug as #2301719: hook_requirements warnings.).

Attached is a re-roll with these issues addressed.

NOTE FOR MAINTAINERS: If/when this patch is commited, it should probably be the start of a new branch of Facebook Autopost. The OP's original patch seemed to have two sets of logic implemented -- one for detecting and using the legacy v3 version of the SDK, and one for v4/v5 -- but the v3 code was then just commented out. Initially, I thought I could just uncomment that and polish it up, but a lot of the changes to the way the API is used are breaking changes that won't work in v3 so instead it looks like we just need a new major version of the module to work with v4 of the Facebook SDK.

There's also some question as to whether calendar events should be included anymore (i.e. FBAutopostEntityEvent), since the API no longer allows us to create, update, or delete them. There's also no longer support for actions on Posts, so the special class for FBAutopostPost seems kind of pointless now.

GuyPaddock’s picture

FileSize
26.18 KB

Found some remaining issue with hook_requirements.

GuyPaddock’s picture

Title: Compatiblity with Facebook PHP SDK v5 and Graph API 2.5 » Compatibility with Facebook PHP SDK v5 and Graph API 2.5

Correcting issue title.

GuyPaddock’s picture

Added to the patch the removal of the "actions" field from "Post" publication types, as it no longer exists.

I'm not removing my old version of the patch, in case I'm mistaken here. Feedback welcome.

GuyPaddock’s picture

If you are running on a version of PHP earlier than 5.6, after applying the patch from this thread, also apply the patch from #2763517: hash_equals() (required by Facebook SDK) is not available in PHP 5.4.

GuyPaddock’s picture

Setting back to NW since the exception types have also changed...

GuyPaddock’s picture

Status: Needs review » Needs work
tommaso.asciolla’s picture

Hi,
the patch did not work for me.

Can you attach fb_autopost module with patch?

Thanks,
Tommaso

scsmith’s picture

I too would love to find a "fully patched" version. I have a WORKING version now, but I really wish this module would get a new maintainer (hint hint Guy Paddock, or new interest from its original developer. This module does exactly what I want - I'm just afraid it will stop working any day!

scsmith’s picture

Please see this issue (https://www.drupal.org/node/2909088) if you are interested in having this module updated! I'm helping to look for some "sponsors". I'm willing to pitch in...are you?

dnd’s picture

Hi!
Anyone knows how to upgrade graph api from version 2.5 to higher 2.8, 2.9, ... on fb_autopost module?
I 've Facebook sdk 5.5.

Thanks in advise!