how to create authentication string for each twitter API call
Created by Jerry Wang on Aug 16, 2014
The following information must be available to populate authentication string for current twitter API call:
Step1
generate the intermediate authentication string by concatenate the technical name of each field and its value into single line by “%3D”, then concatenate each single line into the intermediate string by “%26”.
Step2
generate the base authentication string via the following logic:
The string populated in this step should be:
<current http request name>&<current twitter API url>&<intermediate authentication string generated in step1 >
A sample base authentication string looks like as below:
GET&http%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fmentions_timeline.json&oauth_consumer_key%3DdbsDIeSbFjl7J5UuXXBb8g%26oauth_nonce%3D3DC99B81145ED0726C20207FB8B6A0A8%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1365573543%26oauth_token%3D1322278441-fhsyXxAY3yRLCgJxxQwN7IoRWr73CiJ2ogA08s9%26oauth_version%3D1.0
Step3
Generate authentication string for field “oauth_signature” using HMAC-SHA1 algorithm.
The input parameters for the generation in this step are:
-
Encryption key: consists of consumer secret and token secret combined with “&”.
-
Base authentication string generated from step2.
For detail how to use HMAC-SHA1 algorithm to generate authentication string, please refer to attached sample code.
Step4
During this step value for all seven fields listed in table1 should be available.
Then the following steps must be done to generate the final authentication string:
-
Concatenate field name with field value by “=”.
-
Surround field value with “.
-
Concatenate each name-value pair with “, “.
-
Add header “OAuth “ into the beginning of string.
You can use the following sample authentication string as a reference.
OAuth oauth_consumer_key=“ajaTgSs6QlXni558PjNg”, oauth_token=“1003016971-gRDT3Db0fcnaEvnldIGqrRH6P1Bsu6qXAUfs19b”, oauth_timestamp=“1365576176”, oauth_nonce=“C505BDC4FF6B4804A5A0F17EDD5D48EF”, oauth_version=“1.0”, oauth_signature_method=“HMAC-SHA1”, oauth_signature=“Yj%2BA3IrvgzWpNImngMV1gvnnbiU%3D”
For more detail information about OAuth protocol please refer to following links:
相关文章
- 天气预报api免费接口_天气API
- Gitlab CI/CD 实践六:统一管理 protocol buffer,API 大仓设计与实现
- REST API和SOAP API之间的区别
- 抖音无水印解析最新API接口源码 2022.09.17更新
- oracle soap api,Web API与SOAP API的区别
- Wordpess REST API 错误排查记录
- php调用第三方api接口_uniapp ios原生插件开发
- 彩虹聚合登录中转API程序源码
- 抖音API接口_抖音榜单数据api接口
- 千锋重庆IT学习之微信API接口文档
- 百度翻译api调试
- RESTful API 主流API风格
- 关于Java&JavaScript中(伪)Stream式API对比的一些笔记
- Zuul实现微服务的API网关(一)
- 快速上手Vue Router和组合式API:创建灵活可定制的布局
- Camera 仿微信相机 利用MediaCodec API 从录制MP4到解析播放详解手机开发
- 掌握Oracle数据库API的神奇力量(oracle数据库api)
- Oracle:是否具备API?(oracle有api吗)
- MySQL的API接口:快速、便捷的数据库访问方式(mysql的api接口)
- 操作Redis的API操作:最佳实践(redis的api)
- Oracle函数API:能够极大提升编程效率(oracle函数api)
- 深入理解Linux内核API(linux内核api)
- API实现Mysql数据写入的完美解决方案(api 写入mysql)
- 简易Redis操作开启通用API之旅(redis 通用api)
- [图]微软Google正合作 为Chromium浏览器开发全新虚拟键盘API
- Google二维条码API整理