2011-08-08 20 views
1

這是錯誤我得到:得到錯誤錯誤的URI時把Facebook的訪問令牌的網址

Bad Request 

bad URI `/v1/user/authenticate.json?access_key=1443560867|2.AQBCC2jMKOEzSjnO.3600.1312826400.0-1129666978|VttMJncSU17Br-g38R9eGF5_qCQ'. 

在認證方法:

require 'open-uri' 

class UserController < ApplicationController 

    respond_to :json 

    def authenticate 

    file = open(URI.encode("https://graph.facebook.com/me/permissions?access_token=" + params[:access_key])) 

    facebook = JSON.parse(file.read) 

    if facebook["data"].present? 
     @result = "200" 
    else 
     @result = "403" 
    end 

    respond_with(@result) 

    end 

end 

編輯:解決代碼工作在Heroku .. 。問題在本地:3000

回答

2

在Webrick服務器上,只需將以下內容添加到config/environments/development.rb:

# Allow webrick to accept pipe char in query string 
URI::DEFAULT_PARSER = URI::Parser.new(:UNRESERVED => URI::REGEXP::PATTERN::UNRESERVED + '|') 
相關問題