atymic/twitter

Call to undefined method Atymic\Twitter\Service\Accessor::getRequestToken()

Kamleshpaul opened this issue ยท 5 comments

use Atymic\Twitter\Facade\Twitter;

Route::get('twitter/login', ['as' => 'twitter.login', static function () {
    $token = Twitter::getRequestToken(route('twitter.callback'));

    if (isset($token['oauth_token_secret'])) {
        $url = Twitter::getAuthenticateUrl($token['oauth_token']);

        Session::put('oauth_state', 'start');
        Session::put('oauth_request_token', $token['oauth_token']);
        Session::put('oauth_request_token_secret', $token['oauth_token_secret']);

        return Redirect::to($url);
    }

    return Redirect::route('twitter.error');
}]);

i tried this as per documentaion

i m getting this error

Call to undefined method Atymic\Twitter\Service\Accessor::getRequestToken()

using

  • laravel 7.x
  • php 7.3
  • "atymic/twitter": "^3.1"
reliq commented

Hi @Kamleshpaul, that error suggests that you are trying to use that API v1 method with API v2 selected. Please ensure 1.1 is set as TWITTER_API_VERSION.

when i changed api 1.1 i got another error

Atymic\Twitter\Exception\Request\ForbiddenRequestException
A request error occurred. Client error: GET https://api.twitter.com/oauth/request_token?oauth_callback=http%3A%2F%2Flarryville.test%2Ftwitter%2Fcallback resulted in a 403 Forbidden response: Callback URL not approved for this client application. A (truncated...)

TWITTER_API_VERSION=1.1 and above code in web.php

reliq commented

Hi @Kamleshpaul.

That response suggests your client does not have the appropriate permissions. Please ensure that you are using the correct credentials from your developer portal.

See: https://developer.twitter.com/en/portal/projects-and-apps

@reliq i install older version and it works "atymic/twitter": "^2.3",

thanks

reliq commented

You're welcome.

I verified it still works in ^3.1.

I'll close out this issue now. If you run into further issues please let us know.