cURL post data to asp.net page

只愿长相守 提交于 2019-11-30 22:37:53

What you want is http_build_query, which will format an array as proper HTTP parameters.

Edit: To clarify what this should probably look like:

$params = array(
    '__EVENTTARGET' => 'ctl00$ContentPlaceHolder1$gRef',
    '__EVENTARGUMENT' => '$2',
    '__VIEWSTATE' => $viewState,
    'ctl00$ContentPlaceHolder1$ddlName' => 'Abc'
);

curl_setopt($curlHandler, CURLOPT_POSTFIELDS, http_build_query($params));

Also, what's ctl00$ContentPlaceHolder1$ddlName supposed to be?

Don't urlencode() the ampersands (&) linking the parameters together, just the keys & values (the stuff on either side of the ampersands).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!