使用 Facebook 的 PHP SDK,我能够在我的网站上快速登录 Facebook.他们只需设置一个可以很容易访问的 $user
变量.
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 easily.
我没有这么幸运地尝试让 Twitter 的 OAuth 登录工作......坦率地说,他们的 github 材料对于 PHP 和网页设计相对较新的人来说是令人困惑和无用的,更不用说许多非官方示例了我曾尝试解决同样令人困惑或过时的问题.
I've had no such luck trying to get Twitter's OAuth login working... quite frankly, their github material is confusing and useless for someone that's relatively new to PHP and web design, not to mention that many of the unofficial examples I've tried working through are just as confusing or are outdated.
我真的需要一些帮助才能让 Twitter 登录工作——我的意思只是一个基本的例子,我点击登录按钮,我授权我的应用程序,它重定向到一个页面,在那里显示登录用户的姓名.
I really need some help getting Twitter login working--I mean just a basic example where I click the login button, I authorize my app, and it redirects to a page where it displays the name of the logged in user.
非常感谢您的帮助.
编辑我知道存在 abraham 的 twitter oauth 但是它几乎没有提供任何让他的东西工作的说明.
EDIT I'm aware of the existence of abraham's twitter oauth but it provides close to no instructions whatsoever to get his stuff working.
我刚刚从 github 尝试了 abraham 的 twitteroauth,它似乎对我来说很好用.这就是我所做的
I just tried abraham's twitteroauth from github and it seems to work fine for me. This is what I did
就是这样.如果您现在导航到 http://www.example.com/twitteroauth,您将获得使用 Twitter 登录",这会将您带到 Twitter,授权请求并让您返回 index.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.
示例将不起作用,但不要担心.按照以上步骤上传到服务器.确保从 github 存储库重命名文件,即 config-sample.php->config.php
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
这篇关于Twitter OAuth (PHP):需要良好的基本示例才能开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!