Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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
Facebook graph api FBG无效请求_Facebook Graph Api - Fatal编程技术网

Facebook graph api FBG无效请求

Facebook graph api FBG无效请求,facebook-graph-api,Facebook Graph Api,我阅读了Facebook Graph API上的文档,但对此我感到困惑 我的代码如下 routes.rb match '/auth/:provider/callback' => 'services#create' 服务控制器.rb if service_route == 'facebook' omniauth['info']['email'] ? email = omniauth['info']['email'] : email

我阅读了Facebook Graph API上的文档,但对此我感到困惑

我的代码如下

routes.rb

  match '/auth/:provider/callback' => 'services#create'
服务控制器.rb

            if service_route == 'facebook'
            omniauth['info']['email'] ? email =  omniauth['info']['email'] : email = ''
            omniauth['info']['name'] ? name =  omniauth['info']['name'] : name = ''
            omniauth['uid'] ?  uid =  omniauth['uid'] : uid = ''
            omniauth['provider'] ? provider =  omniauth['provider'] : provider = ''
            omniauth['credentials']['token'] ? session['fb_access_token'] =  omniauth['credentials']['token'] : session['fb_access_token'] = ''
    def create

    @article = current_student.articles.new(params[:article])
    respond_to do |format|
        if @article.save
            format.html { redirect_to(@article, :notice => 'Το άρθρο δημιουργήθηκε επιτυχώς.') }
            format.xml  { render :xml => @article, :status => :created, :location => @article }


            current_student.facebook.feed!(
                :message => 'Hello, Facebook!',
                :name => 'My Rails 3 App with Omniauth, Devise and FB_graph')
student.rb

 def facebook
    @fb_user ||= FbGraph::User.me(self.services.find_by_provider('facebook').token)
 end
文章\u controller.rb

            if service_route == 'facebook'
            omniauth['info']['email'] ? email =  omniauth['info']['email'] : email = ''
            omniauth['info']['name'] ? name =  omniauth['info']['name'] : name = ''
            omniauth['uid'] ?  uid =  omniauth['uid'] : uid = ''
            omniauth['provider'] ? provider =  omniauth['provider'] : provider = ''
            omniauth['credentials']['token'] ? session['fb_access_token'] =  omniauth['credentials']['token'] : session['fb_access_token'] = ''
    def create

    @article = current_student.articles.new(params[:article])
    respond_to do |format|
        if @article.save
            format.html { redirect_to(@article, :notice => 'Το άρθρο δημιουργήθηκε επιτυχώς.') }
            format.xml  { render :xml => @article, :status => :created, :location => @article }


            current_student.facebook.feed!(
                :message => 'Hello, Facebook!',
                :name => 'My Rails 3 App with Omniauth, Devise and FB_graph')
schema.rb

  create_table "services", :force => true do |t|
    t.integer  "student_id"
    t.string   "provider"
    t.string   "uid"
    t.string   "uname"
    t.string   "uemail"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "token
最后一个问题是当我写文章的时候

   FbGraph::InvalidRequest in ArticlesController#create

   OAuthException :: An active access token must be used to query information about the current user.

最后,代码是正确的。只是在

service.rb

  attr_accessible :provider, :uid, :uname, :uemail, :token
一切都很好