我正在集成两个单独的网站登录。每个站点都使用自己的数据库和用户表。
我的问题是:我如何通过PHP执行远程脚本,就像我向网站提交表单一样?
我希望one站点执行登录脚本,该脚本将外部站点登录脚本作为其自己登录过程的一部分运行。我是否应该设置所需的会话cookie并重定向回当前站点?
我使用的是Opencart和vBulletin。
谢谢
发布于 2013-03-29 06:01:04
下面是如何使用cURL发出POST请求:
//set POST variables
$fields = array(
'firstname' => 'Joe',
'lastname' => 'Smith'
);
//urlify the data for the POST
$fieldsString = join('&', array_map('urlencode', $fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, 'http://somewebsite.com');
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsString);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
// view the results
echo $result;https://stackoverflow.com/questions/15654533
复制相似问题