Twitter OAuth (PHP): Need good, basic example to get started

后端 未结 5 1125
醉话见心
醉话见心 2020-12-07 16:57

Using Facebook\'s PHP SDK, I was able to get Facebook login working pretty quickly on my website. They simply set a $user variable that can be accessed very eas

5条回答
  •  遥遥无期
    2020-12-07 17:32

    I just tried abraham's twitteroauth from github and it seems to work fine for me. This is what I did

    1. git clone https://github.com/abraham/twitteroauth.git
    2. Upload this into your webhost with domain, say, www.example.com
    3. Go to Twitter Apps and register your application. The changes that you need are (assuming that you will use abraham's twitteroauth example hosted at http://www.example.com/twitteroauth)
      a) Application Website will be http://www.example.com/twitteroauth
      b) Application type will be browser
      c) Callback url is http://www.example.com/twitteroauth/callback.php (Callback.php is included in the git source)
    4. Once you do this, you will get the CONSUMER_KEY and CONSUMER_SECRET which you can update in the config.php from the twitteroauth distribution. Also set the callback to be the same as http://www.example.com/twitteroauth/callback.php

    Thats it. If you now navigate to http://www.example.com/twitteroauth, you will get a "Signin with Twitter", that will take you to Twitter , authorize the request and get you back to the index.php page.

    EDIT: Example will not work but do not worry. Follow the above steps and upload to server. Make sure you rename the file from github repository i.e. config-sample.php->config.php

    if you want to see a working sample, find it here

提交回复
热议问题