如何知道哪些网站的要求通过PHP服务的外部形象? [英] How to know which website ask for an external image served by php?

查看:146
本文介绍了如何知道哪些网站的要求通过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密钥的网站是一样的一个请求的形象。

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?

感谢您的帮助。

推荐答案

不幸的是,引用站点头是你可以使用这个唯一的东西。是的,它可能是不可靠的,而且肯定是容易伪造。但是,它会提供一些​​保护你。

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天全站免登陆