2016-11-01 57 views
0

我在我的代碼中擁有以下權限,並且Facebook已批准public_profile,publish_actions,publish_pages。我怎樣才能以編程方式爲某些用戶發佈視頻,但是對於其他人卻獲得了權限問題?Facebook有publish_actions但仍然拋出(#100)沒有權限爲某些用戶發佈視頻

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 \"[email protected]#{episode_file_path}\"" 

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

用戶可以選擇不權限授予您的應用程序。你需要處理這種情況 – WizKid

+0

我問用戶他們是否這樣做,他們給我發送了一個在他們的Facebook賬戶上啓用的public_action的屏幕截圖,但它仍然沒有爲他們工作。我需要manage_pages權限嗎? –

+0

如果你想發佈到一個頁面,你需要manage_pages。 – CBroe

回答

0

我不得不manage_pages添加到範圍

相關問題