twitter php_php调用twitter api

今天做了一个关于调用twitter api来同步twitter信息到自己网站的功能,虽然是比较简单的功能,着实花费了我不少时间。网上有很多关于twitter api调用的方法,我试了几个都没有成功,貌似需要Oauth验证,这个跟微信开发类似,需要token验证。后来看到下面这篇博客解决了,讲的挺详细的。

主要步骤是:

第一步:到https://dev.twitter.com/apps/网站上创建一个app,获取验证需要的Consumer key, Consumer secret, Access token, Access token secret这四个参数。

第二步:引入twitteroauth进行验证,这个twitteroauth可以到github上下载,源码都是有的。最后按照给出的php代码运行,调用get或post方法抓取,这里是用到的是curl,twitteroauth里封装了http这样一个方法,里面用curl进行抓取。

Step 1 – Setup a Twitter Application

This process is straightforward and you should have a set of keys within a few minutes.Visit https://dev.twitter.com/apps/ and sign in using your Twitter username and password. This doesn’t have to be the username or password of the stream you need access to, just a Twitter account you control.

Select ‘Create new application’ and enter the application details.The name and description can be anything you like really, but you can’t use ‘Twitter’ in the name.

The website field can be your main website and doesn’t have to be the site where your Twitter feed or feeds are located.

Callback URL can be left blank

Enter the CAPTCHA info and click create

On th

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值