skip to Main Content

I followed his readme and I have done composer dump-autoload a million times, but still I receive an error. Don’t know what i am making wrong. I am trying to use v2 version of twitter api. Please help me anyone.

In config/app.php:

'providers' => [
    ...
    AtymicTwitterServiceProviderLaravelServiceProvider::class,

],

'aliases' => [

    ...
    'Twitter'   => AtymicTwitterFacadeTwitter::class,
],

In my controller:

namespace AppHttpControllers;
use IlluminateHttpRequest;
use Twitter;
class HomeController extends Controller {

    public function index() {
        $tweets = Twitter::getUserTimeline([
            'screen_name' => 'xxxxxxx',
            'count'       => 10,
            'format'      => 'json'
        ]);

        dd($tweets);

        return view('home');
    }

    public function about() {
        return view('about');
    }
}

But I am getting this error:

Error
Call to undefined method AtymicTwitterServiceAccessor::getUserTimeline()

3

Answers


  1. Look like you have to import facade

    Instead of this

    use Twitter;
    

    Import this

    use AtymicTwitterFacadeTwitter;
    

    If you are using alias then run following command

    php artisan config:clear
    
    composer dump-autoload
    
    php artisan optimize
    
    Login or Signup to reply.
  2. Please look to the twitter api version which you have defined in the .env. you may need to use 1.1 and you are using v2

    Login or Signup to reply.
  3. I think getUserTimeLine is available for version 1.1, and I think as the readme says you can use userTweets for v2

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search