Currently, the Social Post Facebook module does not support Social API 2.x/Social Post 2.x, which you may possibly be using with Social Post Twitter 2.x.

I am working on a patch that gets it working.

Comments

joshua.boltz created an issue. See original summary.

joshua.boltz’s picture

Patch that fixes up Social Post Facebook so it can work with the Social API / Social Post 2.x modules.

gnuget’s picture

While I don't maintain the branch 2.x of this module I will be happy to review and merge your work, I will try to do the review of all your patches this week.

And now that Facebook deprecated the publish_actions permission I will move #2907167: Allow publish on a facebook page not just on user profiles. to critical.

Thank you for all your work.

David.

gnuget’s picture

Status: Active » Needs work

Hi Joshua.

I've reviewed your patch and looks great, thanks! I didn't now the state of the branch, so I spent time cheking what was different from the 8.x-1.x version thanks for complete the missing methods, all looks good I just have a few nits, please let me know if you want to discuss one of the following points or if I can help you with something:

  1. @@ -74,7 +74,7 @@ class FacebookPostAuthManager extends PostManager\PostManager {
        *   Absolute Facebook login URL where user will be redirected
        */
       public function getFbLoginUrl() {
    -    $scopes = ['publish_actions'];
    +    $scopes = ['publish_actions', 'email'];
     
         $login_url = $this->client->getAuthorizationUrl([
           'scope' => $scopes,
    @@ -138,4 +138,8 @@ class FacebookPostAuthManager extends PostManager\PostManager {
        

    The publish_actions permission has been removed from the facebook api (more info here) and this is triggering a fatal error when is link the accounts, this is why I updated #2907167: Allow publish on a facebook page not just on user profiles. as critical.

    This permission is still working for you? in my opinion we should remove this asap.

    Also, the email, is the the email permission used for something else? in the Branch 1.X I actually added a text area where the developer could ask whatever permission they wish, I think we can left the email for now but we should consider to backport what I did in the other branch, I think it can stay for now.

  2.  /**
        * The url generator.
    @@ -43,24 +38,22 @@ class FacebookPost extends SocialPostNetwork {
       /**
        * Facebook connection.
        *
    -   * @var \League\OAuth2\Client\Provider\FacebookOAuth
    +   * @var Facebook SDK
        */
       protected $connection;
    

    Accord with the Drupal Standards the type must be with the fully-qualified namespace (more info here) so, we should revert this change.

  3. @@ -72,8 +65,7 @@ class FacebookPost extends SocialPostNetwork {
           $plugin_id,
           $plugin_definition,
           $container->get('entity_type.manager'),
    -      $container->get('config.factory'),
    -      $container->get('logger.factory')
    +      $container->get('config.factory')
         );
    

    I don't think we should get rid of the logger, it is always good leave messages if something went wrong. Actually the logger should come from the parent (the NetworkBase) so the classes which extends the SocialPostNetwork can just use the logger right away, I would say: let's leave it and create an issue in the social_api module.

  4.     +    return new \Facebook\Facebook([
    +      'app_id' => $settings->getAppId(),
    +      'app_secret' => $settings->getAppSecret(),
    +      'default_graph_version' => 'v2.2',
    +    ]);
      

    The social_post_facebook 8.x-2.x settings page allows the user to set the graph_version, we should use that value, no?

  5. +   */
    +  public function getSdk2();
    +
    +}
    \ No newline at end of file
    
  6. All the files must finish with an empty line.

David.

  • joshua.boltz authored ad09fcb on 8.x-2.x
    Issue #2990764 by joshua.boltz, gnuget: Support for Social API 2.x
    
gnuget’s picture

Status: Needs work » Fixed

Hi!

I had time today and I committed your patch and after did the following changes:

  • I removed the sdk2 method and rewrote the sdk method to use your code (and the native Facebook SDK)
  • Removed the deprecated_actions method which make this module unusable without custom code :-(
  • Renamed the getFbLoginUrl to getAuthorizationUrl
  • I removed unsued code in the FacebookPostSettingsForm.php and fixed the oauth path.

Thank you for your help on this one.

joshua.boltz’s picture

Great, thanks David! I'll work on giving that some good testing 8.x-2.x this weekend.

If you want to reach out to me via Drupal Slack, it would be appreciated, maybe together we can figure out a resolution to https://www.drupal.org/project/social_post_facebook/issues/2907167? I did ping you about some things there, but maybe you are not around.

I think mainly I'm stuck on how to get the proper permissions needed to do a post to a Facebook Page, with the `publish_actions` permission being gone. If you have any paths forward, I would be happy to attempt a patch to add that support.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.