我有以下代码从本地站点登录表单(用
PHP编写)登录到外部站点应用程序(asp.net app):
原文链接:https://www.f2er.com/php/134534.html<?PHP $curl_connection = curl_init('www.external.com/login.aspx'); curl_setopt($curl_connection,CURLOPT_CONNECTTIMEOUT,30); curl_setopt($curl_connection,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection,CURLOPT_RETURNTRANSFER,true); curl_setopt($curl_connection,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($curl_connection,CURLOPT_FOLLOWLOCATION,1); // Post data array $post_data['LoginControl$UserName'] = 'ExampleUName'; $post_data['LoginControl$Password'] = 'ExamplePWord'; // Add form fields into an array to get ready to post foreach ($post_data as $key => $value) { $post_items[] = $key . '=' . $value; } $post_string = implode ('&',$post_items); // Tell cURL which string to post curl_setopt($curl_connection,CURLOPT_POSTFIELDS,$post_string); // Execute and post $result = curl_exec($curl_connection); ?>
我被定向到外部站点的登录表单,而不是被定向到登录的应用程序.我认为问题是我需要传递viewstate值,但我不知道该怎么做呢?
我无法控制外部应用程序.但我们希望用户能够通过我们的网站登录该应用程序,以维护品牌等.
我最近发布了一些关于PHP cURL使用的其他线程,但我现在正处于我认为viewstate是问题的阶段……
谢谢,马克.