Facebook有publish_actions但仍然被抛出(#100)没有权限为某些用户发布视频

时间:2016-11-01 02:09:26

标签: facebook facebook-graph-api

我的代码中有以下权限,Facebook已批准public_profile,publish_actions,publish_pages。为什么我可以通过编程方式为某些用户发布视频,但对于其他用户,他们会收到权限问题?

scope: 'email,publish_actions,publish_pages'

上传代码

  def start_upload
    response = request(upload_phase: :start, file_size: File.size("#{episode_file_path}"))
    if response.code == '200'
      @upload_session_id = JSON.parse(response.body)["upload_session_id"]
    else
      raise response.body
    end
  end

  def transfer_upload
    response =JSON.parse(transfer_file)
    if response["start_offset"] != response["end_offset"]
      raise response
    end
  end

  def finish_upload
    response = request(upload_phase: :finish, title: @title, description: @description)
    if response.code != '200'
      raise response.body
    end
  end

  def url
    "https://graph-video.facebook.com/v2.3/#{@post_id}/videos"
  end

  def episode_file_path
    "#{Rails.root}/public/episode_soundbite/#{@episode_id}/video.mp4"
  end

  def request(params)
    Net::HTTP.post_form(URI.parse(url), params.merge(access_token: @oauth_token, upload_session_id: @upload_session_id))
  end

  def transfer_file
    command =  "curl -X POST \"#{url}\"  \
                      -F \"access_token=#{@oauth_token}\" \
                      -F \"upload_phase=transfer\" \
                      -F \"start_offset=0\" \
                      -F \"upload_session_id=#{@upload_session_id}\" \
                      -F \"video_file_chunk=@#{episode_file_path}\""

    response = ''
    IO.popen('-') { |p|
      if p.nil? then
        $stderr.close
         exec command
      end
      response  = p.read
    }
    return response
  end

1 个答案:

答案 0 :(得分:0)

我必须将manage_pages添加到范围