Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails Facebook成就错误_Ruby On Rails_Facebook Graph Api - Fatal编程技术网

Ruby on rails Rails Facebook成就错误

Ruby on rails Rails Facebook成就错误,ruby-on-rails,facebook-graph-api,Ruby On Rails,Facebook Graph Api,我正在尝试使用RoR 3.2.8在Facebook上注册新的成就 下面是我的控制器的动作 require 'net/http' require 'uri' ... def create # achievement url @url = "http://smth.herokuapp.com/achievements/fb/ach.html" # fb graph api url @fbcall = "https://grap

我正在尝试使用RoR 3.2.8在Facebook上注册新的成就

下面是我的控制器的动作

require 'net/http'
require 'uri'

...
    def create
        # achievement url
        @url = "http://smth.herokuapp.com/achievements/fb/ach.html"
        # fb graph api url
        @fbcall = "https://graph.facebook.com/#{FB_APP_ID}/achievements"
        uri = URI(@fbcall)
        res = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_PEER) do |http|
            req = Net::HTTP::Post.new(uri.path)
            req.set_form_data('access_token' => FB_APPLICATION_TOKEN, 'achievement' => @url, 'display_order' => '5')
            response = http.request req
        end
        @ans = res.body.to_s()
    end
每次我都会得到以下
@ans

{"error":{"message":"(#3502) Object at achievement URL is not of type game.achievement","type":"OAuthException","code":3502}}
但是,
@url
上的html已

<meta property="og:type" content="game.achievement" />

财产在其中。 如果我把这个html放到Facebook调试器中,它不会显示任何错误,并且会将类型识别为game.acquisition。 如果我使用输入编写HTML表单,使加载时自动提交,那么就可以创建成果

所以我从rails控制器发送请求的方式似乎有问题


请提供任何帮助。

我注意到,如果我先将成就
@url
放入facebook调试器,它就会注册相应的成就。 现在我做两个ajax请求:第一个请求到facebook调试器,然后(在第一个请求完成后)到facebook图形api