开发者

How do I convert this cURL command to PHP (libcurl)?

In continuation off of this question, what are the PHP statements I need to accomplish this:

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]\+'

The flags and fields are still mysterious, and I've not the time presently to swim through docs to figure out how this translates. I do at least understand the | grep ... portion, though.


You don't need curl for that:

$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]
}

Note that this might need modifications; checking the form at http://hiveminder.com/splash, it seems to require something more complicated than what your curl line uses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜