artdarek / oauth-4-laravel

OAuth Service Provider for Laravel 4
684 stars 216 forks source link

Twitter OAuth Error Failed to request resource. when try to post a status. #76

Open ntwobike opened 10 years ago

ntwobike commented 10 years ago

I make sign up user via your twitter example https://github.com/artdarek/oauth-4-laravel/issues/5. then i stored the token in my db, then i use that token to do other twitter operations like get followers, update status it worked fine when user do those operations just after he logged in but after like 10min when try to update status it isn't worked, im getting Failed to request resource. same time i tried to request "/account/verify_credentials.json" and "/followers/list.json" it worked. Cant i use this token to do POST request?

Here is my code

    $user = $this->user->getLoggedUser();

    $auth_token = $user->twitter_auth_token;

    $oauth_verifier = Input::get( 'oauth_verifier' );

    // get fb service
    $twitterService = Artdarek\OAuth\Facade\OAuth::consumer( 'Twitter' );
    $token = $twitterService->getStorage()->retrieveAccessToken('Twitter');

    if($auth_token){
        $auth_token = unserialize($auth_token );
        $token =$auth_token;

    }else{
         $token = $twitterService->getStorage()->retrieveAccessToken('Twitter');
    }
    //$result = json_decode( $twitterService->request( '/account/verify_credentials.json') );
     //working

    //$friends = json_decode( $twitterService->request( "https://api.twitter.com/1.1/followers/list.json?cursor=-1&user_id=myname&skip_status=true&count=200&include_user_entities=false"));
    //working

    $response = json_decode( $twitterService->request( '/statuses/update.json' , 'POST' , array('status'=>'sample status'));
    //not working