2010-06-07 146 views
0

在延續斷this question,什麼是PHP語句,我需要做到這一點:如何將此cURL命令轉換爲PHP(libcurl)?

curl -is -F 'J:A-login=BTDT::Action::Login' -F 'J:A:F-address-login=EMAILADDRESS' -F 'J:A:F-password-login=PASSWORD' http://hiveminder.com/splash | grep -o 'JIFTY_SID_HIVEMINDER=[0-9a-f]\+' 

的標誌和領域仍然是神祕的,我已經不是目前的時間通過文檔遊弄清楚如何這翻譯。不過,我至少明白| grep ...部分。

回答

1

你不需要捲曲爲:

$data = array(
    "J:A-login"    => 'BTDT::Action::Login', 
    "J:A:F-address-login" => 'EMAILADDRESS', 
    "J:A:F-password-login" => 'PASSWORD', 
); 
$context = stream_context_create(
    array( 
     'http' => array( 
      'method' => 'POST', 
      'header' => "Content-type: application/x-www-form-urlencoded\r\n", 
      'content' => http_build_query($data), 
      'timeout' => 10, 
     ), 
    ) 
); 

$ret = file_get_contents('http://hiveminder.com/splash', false, $context); 
if (preg_match('/JIFTY_SID_HIVEMINDER=[0-9a-f]+/m', $ret, $matches)) { 
    //see $matches[0] 
} 

注意,這可能需要修改;在http://hiveminder.com/splash檢查表格,它似乎需要比捲曲線使用更復雜的東西。

+0

是的,無論如何,我想知道所有這些cURL業務是爲了什麼。萬分感謝! – 2010-06-07 07:28:34