2010-06-07 153 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