2012-03-15 100 views
0

我正在實施Facebook批處理過程以使用單個請求上傳多個圖像。 我使用在給出的簡單的例子:Facebook批處理錯誤

而且我的代碼如下:

$str = "curl 
    –F ‘access_token=…’ \ 
    -F ‘batch=[{ 
        「method」:」POST」, \ 
        「relative_url」:」ALBUM_ID/photos」, \ 
        「body」:」message=My photo」 \ 
        "attached_files":"file1" \ 
       }, 
       { 
        「method」:」POST」, \ 
        「relative_url」:」ALBUM_ID/photos」, \ 
        「body」:」message=My photo」 \ 
        "attached_files":"file2" \ 
       }, 
       { 
        「method」:」POST」, \ 
        「relative_url」:」ALBUM_ID/photos」, \ 
        「body」:」message=My photo」 \ 
        "attached_files":"file3" \ 
       }, 
       ]’ 
    -F ‘[email protected]’ \ 
    -F '[email protected]' \ 
    -F '[email protected]' \ 
    https://graph.facebook.com " 
exec($str, $error); 

當我檢查我的$error變量它表明我"curl: -F not found"

如果我在瀏覽器上回顯該字符串,然後在終端上覆制/過去確實對我有用。

我不明白爲什麼這不適用於PHP。

謝謝!

+0

嘗試從各行的結尾處,刪除 「\」。 – Smit 2012-03-15 16:54:26

+0

不,不工作..給我錯誤,如「-F主機未找到」:( – Smit 2012-03-15 16:55:49

回答

0

確定,儘量做到以下幾點:

$str = str_replace("\n"," ",$str); 
exec($str); 

這應該工作..

+0

YEAH,謝謝..那個工作... 但爲什麼複製/過去的工作和瀏覽器它不會? – Smit 2012-03-15 17:09:52

+1

嘗試使用 echo'

'; print_r($str); echo '
'; 你會知道原因:) – Smit 2012-03-15 17:12:49