Zend Framework: Zend_Oauth and Zend_Service_Twitter

后端 未结 3 578
慢半拍i
慢半拍i 2021-02-06 14:57

First of all, I am able to successfully authenticate using Oauth. I am using Padraic\'s tutorial found here: http://blog.astrumfutura.com/archives/411-Writing-A-Simple-Twitter-C

3条回答
  •  情话喂你
    2021-02-06 15:49

    Okay, I placed a bounty on this question and I do not know how to remove it. I am going to answer it myself. For others to know if they are encountering the same problem.

    First, in my application.ini I have something like this:

    oauth.version           = "1.0"
    oauth.signatureMethod   = "HMAC-SHA1"
    oauth.requestScheme     = "header"
    oauth.siteUrl           = "http://mysite.com/twitter/public"
    oauth.callbackUrl       = "http://mysite.com/twitter/public/login/callback"
    oauth.requestTokenUrl   = "http://twitter.com/oauth/request_token"
    oauth.authorizeUrl      = "http://twitter.com/oauth/authorize"
    oauth.accessTokenUrl    = "http://twitter.com/oauth/access_token"
    oauth.consumerKey       = "xxxxxx"
    oauth.consumerSecret    = "xxxxxxxxxx"
    

    Then, my new model is this:

    _config = new Zend_Config_Ini(APPLICATION_INI, APPLICATION_ENV);
            $this->_token = $token;
            $this->setUri('http://twitter.com');
            //$this->_authInitialized = true;
    
            self::setHttpClient($token->getHttpClient($this->_config->oauth->toArray()));
        }
    }
    

    Using it would look something like this:

    $oauth = new Zend_Session_Namespace('Twitter_Oauth');
    $token = unserialize($oauth->twitter_access_token);
    $this->_twitter = new Mytwitterapp_Twitteroauth($token);
    

提交回复
热议问题