Skip to content

Instantly share code, notes, and snippets.

@tlayh
Last active August 29, 2015 13:56
Show Gist options
  • Save tlayh/9303920 to your computer and use it in GitHub Desktop.
Save tlayh/9303920 to your computer and use it in GitHub Desktop.
Get the login URL to sign in with twitter
/**
* get the login url from oauth
*
* @return string $loginUrl
*/
public function getLoginUrl() {
// create the twitterOAuth object using your consumer_key and consumer_secret, after creating an app on
// dev.twitter.com/apps
$this->twitterOAuth = new TwitterOAuth($this->consumerKey, $this->consumerSecret);
// get a request token from twitter
$requestToken = $this->twitterOAuth->getRequestToken($this->callback);
$this->oauthToken = $requestToken['oauth_token'];
$this->oauthTokenSecret = $requestToken['oauth_token_secret'];
// get the url to make it possible to login.
$loginUrl = $this->twitterOAuth->getAuthorizeUrl($this->oauthToken);
return $loginUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment