内容简介:翻译自:https://stackoverflow.com/questions/11582395/how-should-i-check-if-gravatar-exist
使用这个宝石
https://github.com/sinisterchipmunk/gravatar
我如何检查指定电子邮件的格式是否存在?我想我错过了一些强制默认选项?因为这
url = Gravatar.new("generic@example.com").image_url
总是回来一张照片
看一下gem的文档,听起来你需要一个API密钥才能运行exists方法:
Fine, but how about the rest of the API as advertised at en.gravatar.com/site/implement/xmlrpc? Well, for that you need either the user’s Gravatar password, or their API key: api = Gravatar.new(“generic@example.com”, :api_key => “AbCdEfG1234”) api.exists?(“another@example.com”) #=> true or false, depending on whether the specified email exists.
如果用户没有gravatar,将根据电子邮件为他们生成图像(至少这是我的经验).我使用了gem gravatar_image_tag – http://rubygems.org/gems/gravatar_image_tag ,它可以让你更改默认的gravatar图像.
翻译自:https://stackoverflow.com/questions/11582395/how-should-i-check-if-gravatar-exist
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Beautiful Code
Greg Wilson、Andy Oram / O'Reilly Media / 2007-7-6 / GBP 35.99
In this unique work, leading computer scientists discuss how they found unusual, carefully designed solutions to difficult problems. This book lets the reader look over the shoulder of major coding an......一起来看看 《Beautiful Code》 这本书的介绍吧!