ruby-on-rails – 我应该如何检查是否存在gravatar?

栏目: Ruby · 发布时间: 6年前

内容简介:翻译自: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 users 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


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

软件测试

软件测试

[美]Ron Patton / 张小松、王珏、曹跃 / 机械工业出版社 / 2006-4 / 30.00元

软件测试(原书第2版),ISBN:9787111185260,作者:(美)佩腾(Patton,R.) 著,张小松 等译;张小松译一起来看看 《软件测试》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具