There are no errors I can see, but the post never makes it to the facebook page. What am I missing?
I can create an action in the Rules ui that posts the item to my main fb user's Timeline, but I want it to post to the page I specify, which I do not own, but have Administrator privileges on. What gives?

facebook api version 2.5

I followed instructions here: http://www.function1.com/2014/11/publish-directly-to-facebook-from-your-...

I modified the rule from 'link'-specific to 'blog'-specific, the 4 changed items are bolded:

{ "rules_facebook_autopost_" : {
"LABEL" : "Facebook Autopost ",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "fb_autopost_entity" ],
"ON" : { "node_insert" : [] },
"IF" : [
{ "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "blog" : "blog" } } } }
],
"DO" : [
{ "entity_create" : {
"USING" : {
"type" : "facebook_publication",
"param_type" : "post",
"param_user" : [ "site:current-user" ]
},
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
},
{ "data_set" : {
"data" : [ "entity-created:field-facebook-message" ],
"value" : "[node:body]"
}
},
{ "data_set" : {
"data" : [ "entity-created:field-facebook-description" ],
"value" : "\u003C?php\r\n$node_view = node_view($node,\u0027summary\u0027);\r\n$summary = $node_view[\u0027body\u0027][0][\u0027#markup\u0027];\r\n\r\nprint strip_tags( $summary );\r\n?\u003E"
}
},
{ "data_set" : {
"data" : [ "entity-created:field-facebook-link" ],
"value" : "[node:url]"
}
},
{ "data_set" : {
"data" : [ "entity-created:field-facebook-name" ],
"value" : "[node:title]"
}
},
{ "data_set" : {
"data" : [ "entity-created:field-facebook-picture" ],
"value" : "[node:field-header-image:file:url]"
}
},
{ "publish_to_facebook" : {
"USING" : { "publication" : [ "entity-created" ], "pages" : "13************15" },
"PROVIDE" : { "facebook_publication_id" : { "facebook_publication_id" : "Facebook publication returned ID" } }
}
}
]
}
}

CommentFileSizeAuthor
#9 fb_autopost.zip70.46 KBmath_1048
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

topdillon created an issue. See original summary.

xadag’s picture

I had the same problem and solve it by :

Create a new app with the 2.5 api version

Apply this patch : https://www.drupal.org/node/2602478 and use the latest SDK PHP of Facebook from https://github.com/facebook/facebook-php-sdk-v4

And also on the facebook autopost permission admin page, set manage_pages, publish_pages permissions to the role authenticated user.

After that going on the facebook autopost admin page, logout from my account and renew login to set permission and autorisation for my facebook account and the app

After i was able to post to my pages. The user must be administrator of pages.

topdillon’s picture

Thanks.

My app is v2.5 and I have pasted in the AppID and Secret.
I also applied the patch successfully.
I downloaded the facebook-php-sdk-v4-master.zip, unzipped it and renamed it facebook-php-sdk and ran 'drush cc all'.
I then chose the autopost permissions as you directed.
Then when I visited the autopost admin page, I see:
"Facebook Autopost could not be started because the Facebook PHP library is missing. Please contact system administration to communicate this error."
What did I miss?

topdillon’s picture

When you say "The user must be administrator of pages", do you mean the fb user, or do you mean the email address of the User account on the D7 site has to be the same as the email address of the fb account?

topdillon’s picture

I re-downloaded the dev version (from Apr 4),
re-applied patch, output:

Daniel:52:~/Sites/mylocalD7site/sites/all/modules/contrib/fb_autopost$ patch -p1 <  update_SDKv5.patch 
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

Then I re-installed sdk with drush, changed name to facebook-php-sdk and ran drush cc all.
The folder permissions are the same as all the other libraries.

I checked my app too. Version 2.5, all fields filled out properly and pasted in Drupal site correctly.
Permissions are very generous for Administrator and Authenticated.
Features is installed.
Entity API is installed.
Yet, I still get the message: "Facebook Autopost could not be started because the Facebook PHP library is missing. Please contact system administration to communicate this error."

What did I miss?

wildfeed’s picture

Look at directory structure of facebook-php-sdk. facebook.php is located at /src/Facebook/facebook.php NOT /src/facebook.php - which is where

 if (file_exists($lib_path . '/src/facebook.php')) {

fb_autopost_requirements() expects it. That's where it was in the deprecated SDK.

I have not gotten the module to work yet, but I have found this to be the case.

topdillon’s picture

Thanks, Xadag.
Got it working today with stable release from 2015-May-15 and instructions in #2.
I also updated the library.
I still had to manually go through all the lines in the patch to manually change the few that did not get fixed.

math_1048’s picture

Hello, please can you upload that working patched version of fb_autopost module..
Thank you very much for help

math_1048’s picture

FileSize
70.46 KB

Hello, My notes about applying steps in comment #2, Thanks for Xadag.
1- to apply patch need to copy patch file to module directory and apply:

# patch -p1 < update_SDKv5.patch

2- download and use this "5.1.2" version of Facebook-sdk, because of newer version will gives an error message because of calling undefined function "Call to undefined function hash_equals()".
the url for 5.1.2 version is:
https://github.com/facebook/facebook-php-sdk-v4/archive/5.1.2.tar.gz
after extract the tar.gz file rename output directory to "facebook-php-sdk-v4".

now its works fine.
I uploaded the patched version of "7.x-1.4" if needed.

Thanks to you all.

GuyPaddock’s picture

The hash_equals error results if you are not running on PHP 5.6 or later. I'll file a separate ticket with a patch that allows FB Autopost to workaround its absence.

edit: See #2763517: hash_equals() (required by Facebook SDK) is not available in PHP 5.4.

GuyPaddock’s picture

Also: I've confirmed that the patch in #2602478: Compatibility with Facebook PHP SDK v5 and Graph API 2.5 should work, and have re-rolled it with some additional clean-up. The key is that you need to make sure that you checkout the code for FB Autopost using GIT, not by downloading it through Drupal.org. Otherwise the patch will not apply cleanly.