Commit 8017bd0b authored by Eleo Basili's avatar Eleo Basili
Browse files

Issue #3258724 by eleonel: Message Error: Call to undefined method...

Issue #3258724 by eleonel: Message  Error: Call to undefined method Facebook\Facebook::getAuthorizationUrl().
parent ab1227de
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Drupal\social_post_facebook;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Drupal\social_post\PostManager;
use League\OAuth2\Client\Provider\Facebook;

/**
 * Manages the authorization process and post on user behalf.
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ class FacebookPostSettingsForm extends ConfigFormBase {
      ->set('app_id', $values['app_id'])
      ->set('app_secret', $values['app_secret'])
      ->set('graph_version', $values['graph_version'])
      ->set('oauth_redirect_url', $values['oauth_redirect_url'])
      ->save();

    parent::submitForm($form, $form_state);
+7 −7
Original line number Diff line number Diff line
@@ -41,11 +41,11 @@ class FacebookPost extends NetworkBase implements FacebookPostInterface {
  protected $urlGenerator;

  /**
   * Facebook connection.
   * Facebook client.
   *
   * @var \Facebook\Facebook
   * @var \League\OAuth2\Client\Provider\Facebook
   */
  protected $connection;
  protected $client;

  /**
   * The status text.
@@ -144,8 +144,8 @@ class FacebookPost extends NetworkBase implements FacebookPostInterface {
    return new Facebook([
      'clientId'          => $settings->getAppId(),
      'clientSecret'      => $settings->getAppSecret(),
      'redirectUri'       => $settings->getOauthRedirectUrl(),
      'graphApiVersion'   => 'v' . $settings->getGraphVersion() . '.0',
      //   'redirectUri' => 'https://example.com/user/social-post/facebook/auth',
     ]);
  }

@@ -177,11 +177,11 @@ class FacebookPost extends NetworkBase implements FacebookPostInterface {
   * {@inheritdoc}
   */
  public function post() {
    if (!$this->connection) {
    if (!$this->client) {
      throw new SocialApiException('Call post() method from its wrapper doPost()');
    }

    $message = $this->connection->post('me/feed', ['message' => $this->status], $this->accessToken);
    $message = $this->client->post('me/feed', ['message' => $this->status], $this->accessToken);

    if ($message->getHttpStatusCode() != 200) {
      return FALSE;
@@ -194,7 +194,7 @@ class FacebookPost extends NetworkBase implements FacebookPostInterface {
   * {@inheritdoc}
   */
  public function doPost($access_token, $status) {
    $this->connection = $this->getSdk();
    $this->client = $this->getSdk();
    $this->status = $status;
    $this->accessToken = $access_token;
    return $this->post();
+11 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class FacebookPostSettings extends SettingsBase implements FacebookPostSettingsI
  protected $defaultToken;

  /**
   * The redirect URL for social_auth implmeneter.
   * The redirect URL for social_auth implementer.
   *
   * @var string
   */
@@ -74,4 +74,14 @@ class FacebookPostSettings extends SettingsBase implements FacebookPostSettingsI
    return $this->graphVersion;
  }

  /**
   * {@inheritdoc}
   */
  public function getOauthRedirectUrl() {
    if (!$this->oauthRedirectUrl) {
      $this->oauthRedirectUrl = $this->config->get('oauth_redirect_url');
    }
    return $this->oauthRedirectUrl;
  }

}