I want to create an API, and to authenticate API consumers, I will provide an API KEY, App-id and App-Secret. The problem is that I want to know where the http Request is coming from, so that I can know if the Host that is making que request is the registered Host. For example : www.someone.com has an app-id :0001, app-secret:1200 and api-key:458. If this credentials are used to make A request, I want to know if the requester is really www.someone.com
关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
已采纳
如何在php中获取http请求源
收起
- 写回答
- 好问题 0 提建议
- 关注问题
- 微信扫一扫点击复制链接分享
- 邀请回答
- 编辑 收藏 删除 结题
- 收藏 举报
5条回答 默认 最新
- 关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
doulu4316 2016-03-26 03:50关注Use
$_SERVER['HTTP_REFERER']
. It is the address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modifyHTTP_REFERER
as a feature.For further restrictions you can perform the following.
example.com
should be changed to your domain.IIS set below in web config:
add name="Access-Control-Allow-Origin" value="http://www.example.com"
Apache set below in httpd.conf/apache.conf
Header add Access-Control-Allow-Origin "http://www.example.com"
本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏举报微信扫一扫点击复制链接分享编辑预览轻敲空格完成输入- 显示为
- 卡片
- 标题
- 链接
评论按下Enter换行,Ctrl+Enter发表内容
编辑
预览
轻敲空格完成输入
- 显示为
- 卡片
- 标题
- 链接
报告相同问题?
提交
- 2022-03-07 13:49回答 2 已采纳 题主的user-agent没看出是移动端的,换下面的其中一个试试Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit
- 2016-01-08 12:34回答 2 已采纳 It's not possible to get the original request string, as far as I know. However, all the informati
- 2019-05-03 08:59回答 1 已采纳 I think you may be confused about how POST requests and HTTP bodies work. Apologies if this is act
- 2021-04-22 03:01weixin_39628070的博客 在PHP中想要读取请求标头,可以使用getallheaders()函数、apache_request_headers()函数来实现。下面本篇文章就来带大家认识PHP读取请求标头的方法,希望对大家有所帮助。HTTP请求标头是什么?在了解HTTP请求标头...
- 2018-08-13 11:57回答 2 已采纳 If you need view x-www-form-urlencoded post data, just use print_r($_POST); If you need view js
- 2017-10-21 21:55回答 1 已采纳 In my comment on your questions I suggested: You could use Apache's mod_rewrite to create a rule
- 2015-12-10 06:15回答 2 已采纳 The problem was the method of the $http request. you have to use POST so PHP can get the values wi
- 2021-01-14 02:15零OO的博客 PHP发送http请求,获取网页内容方法:cURL、file_get_contents()、fopen() 区别: 1. 相较于file_get_contents()、fopen(),cURL支持更多功能 cURL支持更多协议,目前支持http、https、ftp、gopher、telnet、dict、...
- 2017-01-26 02:37回答 2 已采纳 Query string variables that are appended to the url of the page are always seen as get variables,
- 2016-02-05 04:28回答 3 已采纳 I am basing my answer off this answer. Not sure where you got inputvalue from, but replace it with
- 2012-10-01 20:14回答 2 已采纳 Your $construct variable's value contains single quotes, which are not necessary. When you write i
- 2021-04-23 11:29Merryedison的博客 1、php判断http请求还是https请求$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO']...
- 2022-11-10 03:26五个饺子馆的博客 php中如何获取请求头header
- 2021-05-07 00:06weixin_39934257的博客 我目前正在用PHP开发Restful Json-API。我想向items/:id发送一个PUT...我想用curl -H "Content-Type: application/json" -X PUT -d '{"example" : "data"}' "http://localhost/items/someid"在服务器端,我无法检索...
- 2022-03-27 03:58Risehuxyc的博客 PHP获取请求端的浏览器信息和HTTP头部信息。 echo $_SERVER['HTTP_USER_AGENT'],"\n"; echo $_SERVER['HTTP_HOST'],"\n"; echo $_SERVER['HTTP_REFERER'],"\n"; echo $_SERVER['HTTP_COOKIE'];
- 没有解决我的问题, 去提问
悬赏问题
- ¥15 PADS Logic 原理图
- ¥15 PADS Logic 图标
- ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
- ¥20 气象站点数据求取中~
- ¥15 如何获取APP内弹出的网址链接
- ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
联系我们(工作时间:8:30-22:00)
400-660-0108kefu@csdn.net在线客服
- 京ICP备19004658号
- 经营性网站备案信息
- 公安备案号11010502030143
- 营业执照
- 北京互联网违法和不良信息举报中心
- 家长监护
- 中国互联网举报中心
- 网络110报警服务
- Chrome商店下载
- 账号管理规范
- 版权与免责声明
- 版权申诉
- 出版物许可证
- ©1999-2025北京创新乐知网络技术有限公司