When I run opauth/twitter on FuelPHP, it does not transition to Twitter authentication screen.

Asked 2 years ago, Updated 2 years ago, 143 views

We are currently creating a Twitter authentication mechanism with FuelPHP1.8.

As per the documentation, \Auth_Opauth::forge() on the controller will fly directly to the Callback URL.

The environment is
X Server PHP 7.0.3
FuelPHP 1.8

I use Composer to install opauth.

"opauth/opauth": "0.4.*",
"opauth/twitter": "dev-master",
"opauth/facebook": "dev-master"

The controller code is as follows:

class Controller_Oauth extensions Controller
{
  public function action_login($provider=null)
  {
    if($provider===null)
    {
      \Messages::error('login-no-provider-specified');
      \Response::redirect_back();
    }

    \Auth_Opauth::forge();
  }

  public function action_facebook()
  {
    //
  }

  public function action_callback()
  {
    $opauth=\Auth_Opauth::force(false);
  }
}

The Strategy setting is
/path/to/app/config/opauth.php

'Twitter'=>array(
  'key' = > 'gFEQjKSP3apYH6X83JPdFtej7',
  'secret' = > 'kzcjoSCrgtPifMqyt7Pkw2tIReKY0gSCP6fnOpJnTe3prQpzxL'
),

var_dump($opauth) in the callback action returns opauth settings as objects.

Thank you for your cooperation.

php twitter oauth fuelphp

2022-09-30 21:12

1 Answers

I'm deeply into the same problem and I'm going to share it with you.
fuel/vendor/opauth/twitter/vendor/tmhOAuth/tmhOAuth.php
Near the last line of the

\Log::debug(__METHOD__.'.__LINE__.'$this->response='.print_r($this->response,TRUE));

and check the response content

[error]=>SSL:CA certificate set, but certificate verification is disabled
[errno] = > 35

I think it says that
Below is a description of the resolution of this error.
Perhaps the SSL of curl is SecureTransport, not OpenSSL.

 $php-i | grep "SSL Version"
SSL Version=>SecureTransport

If it says so, change it to OpenSSL.

In my case, it's a Mac, so I'll install curl separately with a brew

$brew install --with-opensl curl
Abbreviated.
    LDFLAGS: -L/usr/local/opt/curl/lib
    CPPFLAGS: -I/usr/local/opt/curl/include

Use this to recompile curl.so from the source
Download the same source as your PHP version from http://jp2.php.net/releases/

$cd/usr/local/src
$ tar xjvf php-x.x.xx.tar.bz2
$ cd/usr/local/src/php-x.x.x/ext/curl
$ phpize
(Configure with LDFLAGS and CPPFLAGS values that just came out via brew)
$ ./configure LDFLAGS="-L/usr/local/opt/curl/lib "CPPFLAGS="-I/usr/local/opt/curl/include"
$ make
$ make test
$ sudo make install
$ sudo apachectl restart

Check SSL again for curl

 $php-i | grep "SSL Version"
SSL Version=>OpenSSL/x.x.x

Twitter now passes through Opauth.


2022-09-30 21:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.