我对PHP很新,所以如果你有任何想法或建议指出我正确的方向,我将不胜感激.
尝试创建一个简单的函数来检查用户的电子邮件地址是否转换为有效的Gravatar图像,但似乎gravatar.com已更改其标题.
使用get_headers('urlencoded_bad_email@example.com')返回200而不是302.
以下是来自糟糕的重力图像的标题,其中没有一个似乎能够提供帮助,因为它们与有效的重力图像相同:
array(13) {
[0]=>
string(15) "HTTP/1.1 200 OK"
[1]=>
string(13) "Server: nginx"
[2]=>
string(35) "Date: Sun, 26 Jul 2009 20:22:07 GMT"
[3]=>
string(24) "Content-Type: image/jpeg"
[4]=>
string(17) "Connection: close"
[5]=>
string(44) "Last-Modified: Sun, 26 Jul 2009 19:47:12 GMT"
[6]=>
string(76) "Content-Disposition: inline; filename="5ed352b75af7175464e354f6651c6e9e.jpg""
[7]=>
string(20) "Content-Length: 3875"
[8]=>
string(32) "X-Varnish: 3883194649 3880834433"
[9]=>
string(16) "Via: 1.1 varnish"
[10]=>
string(38) "Expires: Sun, 26 Jul 2009 20:27:07 GMT"
[11]=>
string(26) "Cache-Control: max-age=300"
[12]=>
string(16) "Source-Age: 1322"
}
Run Code Online (Sandbox Code Playgroud)
ps我知道'&d'参数,但它不符合我的目的.:)
编辑:
用'?d'而不是'&d'.必须是gravatar.com'tang.
注意:在撰写本文时,这是唯一的选择。然而,后来?d=404添加了一些时间,使安德鲁的答案更加清晰。
尽管您说您了解该d参数,但您知道它实际上在适用时返回重定向标头吗?因此,以下结果会生成302 Found,因为头像不存在:
HTTP/1.1 302 Found
...
Last-Modified: Wed, 11 Jan 1984 08:00:00 GMT
Location: http://www.google.com/images/logo.gif
Content-Length: 0
...
Expires: Sun, 26 Jul 2009 23:18:33 GMT
Cache-Control: max-age=300
Run Code Online (Sandbox Code Playgroud)
在我看来,您所需要做的就是添加该d参数并检查 HTTP 结果代码。