curl 模擬 http post 提交檔案至 google swiffy 轉檔

edited 三月 2014 in 進階PHP討論
您好:

我的環境為
os:mac
PHP Version 5.3.28

因為我有很多 flash 檔案 必須轉成 html5
所以我利用 google 的 swiffy 來轉檔
swiffy 轉檔後他會給你一個 .html 鏈結
https://www.google.com/doubleclick/studio/swiffy/

因此我利用 curl 來模擬 http post 提交 .swf 檔案
拿到的回傳資料都正常
但是去開啟的 .html 都會說
"This preview is invalid or has expired. Previews are available for 15 minutes."
無法開啟


以下是我的程式碼,煩請高手幫我過目
看問題是出在哪邊,感激不盡!
<?php

$toURL = "https://www.google.com/doubleclick/studio/swiffy/upload";
$post = array(
  'swfFile'=>"@.getcwd()./A0001.swf"

);

$ch = curl_init();
$options = array(
  CURLOPT_URL=>$toURL,
  CURLOPT_POST=>true,
  CURLOPT_HEADER=>0,
  CURLOPT_FOLLOWLOCATION => 1,
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_TIMEOUT=> '20',
  CURLOPT_SSL_VERIFYPEER => false,
  CURLOPT_REFERER => 'https://www.google.com/doubleclick/studio/swiffy/',
  CURLOPT_USERAGENT => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36",
  CURLOPT_POSTFIELDS=>$post, // 直接給array
);
curl_setopt_array($ch, $options);
$r = curl_exec($ch); 
print_r($r);

curl_close($ch);

$r  = strstr($r, '"');
$r2[]  = strstr($r, 'view/o/');
$r3 = substr($r2[0],7,-7 );

//var_dump($r3);



$url = 'https://swiffypreviews.googleusercontent.com/view/o/'.$r3.'A0001.html?clickTAG=https://www.google.com/doubleclick/studio/swiffy/faq.html#clickTAG';

?>

<iframe src="<?php echo $url;?>"></iframe>

評論

Sign In or Register to comment.