如何知道哪个网站要求由 php 提供的外部图像? [英] How to know which website ask for an external image served by php?

查看:21
本文介绍了如何知道哪个网站要求由 php 提供的外部图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个提供图像的 PHP 文件.它要求一个api 密钥"(限制访问)和一个字符串.然后它生成一个PNG图像并返回它.

I have a PHP file serving images. It ask for an "api key" (to limit the access) and a string. Then it generate a PNG image and return it.

访问图片:

<img src="http://www.myserver.com/mypage.php?api=APIKEY&text=some-text-here" alt=""/>

此图片将从第三方网站调用.

This image will be called from third party's website.

我需要知道api key相关的网站是否与要求图片的网站相同.

I need to know if the website related to the api key is the same as the one asking for the image.

我可以获取引荐来源网址,但我知道有时它可能为空.

I can grab the referrer but I know sometimes it can be empty.

我如何验证这些信息?有没有更好的方法来做到这一点?

How can I verify this information? Is there any better way of doing this?

感谢您的帮助.

推荐答案

不幸的是,Referer 标头是您唯一可以使用的标头.是的,它可能不可靠,而且绝对容易被欺骗.但是,它会为您提供一些保护.

Unfortunately, the Referer header is the only thing you can use for this. Yes, it can be unreliable, and is definitely easily spoofed. But, it will provide some protection for you.

这篇关于如何知道哪个网站要求由 php 提供的外部图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆