2016-04-18 39 views
0

我試圖與路邊的寶石相當於捲曲電話:捲曲請求爲Facebook阿比

curl \ 
    -F 'name=My new CA' \ 
    -F 'subtype=CUSTOM' \ 
    -F 'description=People who bought from my website' \ 
    -F 'access_token=<ACCESS_TOKEN>' \ 
    https://graph.facebook.com/v2.5/act_<AD_ACCOUNT_ID>/customaudiences 

到目前爲止,我的代碼如下所示:

cr = Curl::Easy.http_post("https://graph.facebook.com/v2.5/act_XXXXXXXXXXXXXXX/customaudiences?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") do |curl| 
    curl.headers['name']='My new CA' 
    curl.headers['subtype']='CUSTOM' 
    curl.headers['description']='People who bought from my website' 
    curl.headers['access_token']='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
end 

    pp cr.body_str 

但是,作爲一個迴應我得到這個:

=> "{\"error\":{\"message\":\"(#100) Missing parameter(s): subtype\",\"type\":\"OAuthException\",\"code\":100,\"fbtrace_id\":\"BOd\\/mmhQkkP\"}}" 

有人可以解釋我我做錯了什麼? 謝謝!

回答

0

您也可以只使用一個系統調用是這樣的:

name = "something" 
url = "http://www.example.com" 
result = `curl -F 'name=#{name}' #{url}` 

result將持有你的系統調用的輸出。對於更復雜的http請求,您可能需要查看法拉第(https://github.com/lostisland/faraday