0

我正在尝试通过单击 facebook 中的 opengraph 操作来验证访问我网站的用户。

我已经使用以下代码成功生成了操作。这成功地出现在我的时间线上。到目前为止,一切都很好。

require 'cgi'

client_id ="CLIENT_ID"
client_secret = "CLIENT_SECRET"

recipe = "http://foodonthetable.shadr.us/recipes/1007-spanish-chicken-and-rice"
access_token = "LONGACCESSTOKEN"

# PUBLISH
result = `curl -F access_token=#{access_token} -F recipe=#{recipe} https://graph.facebook.com/me/foodonthetable_mrh:plan_to_cook`
puts result

当我单击时间轴中的链接时,我会转到以下 URL。这就是我开始遇到问题的地方。基本上,我想识别通过此链接进入的用户并将他们登录(或创建一个新用户)。我已经打开了经过身份验证的推荐,并且我正在code按预期接收参数。

http://foodonthetable.shadr.us/recipes/1007-spanish-chicken-and-rice?fb_action_ids=384156608318085&fb_action_types=foodonthetable_mrh%3Aplan_to_cook&fb_source=timeline_og&action_object_map=%7B%22384156608318085%22%3A10151004406923956%7D&code=AQAPExNw7MHkxcLTEi5L24iD79pVa-WYxyhBA_bhdWLCM0PCGDuPjh1WqmAyd3_O3_LSjYzPawrinHNP3nv9BCMB_XuTnr8De8xQ2AwXqCaeHUzZUPm2MPyQ_eodOC9-YtjkvXm_PzRX3JG58khalT3AJjVuZvKHn5hWGDSohXLRbHGxW-vOg_Whm3mt_WUkdd0#_=_

但是,当我尝试auth_token使用此代码时,我无法做到。我已经尝试使用redirect_uri可能是问题的几个不同版本的想法(基于其他帖子),但似乎没有任何效果。

redirect_uri = "http://foodonthetable.shadr.us/recipes/1007-spanish-chicken-and-rice"
redirect_uri = "http://foodonthetable.shadr.us/facebook_connect/connect"

code = "AQAPExNw7MHkxcLTEi5L24iD79pVa-WYxyhBA_bhdWLCM0PCGDuPjh1WqmAyd3_O3_LSjYzPawrinHNP3nv9BCMB_XuTnr8De8xQ2AwXqCaeHUzZUPm2MPyQ_eodOC9-YtjkvXm_PzRX3JG58khalT3AJjVuZvKHn5hWGDSohXLRbHGxW-vOg_Whm3mt_WUkdd0"

result = `curl -F client_id=#{client_id} -F redirect_uri=#{redirect_uri} -F client_secret=#{client_secret} -F code=#{code} https://graph.facebook.com/oauth/access_token`
puts result

无论我在这里做什么,我总是收到以下错误:

{"error":{"message":"Error validating verification code.","type":"OAuthException","code":100}}

任何帮助,将不胜感激。

4

1 回答 1

0

这确实解决了它。

redirect_uri = request.url.split('&code=').first
于 2012-08-08T18:01:11.373 回答