donglun1918 2015-02-08 01:31
浏览 62

当我收到带有X-Frame选项的http响应头时,我是否需要在php中使用任何特殊选项准备curl:SAMEORIGIN?

To retrieve a successful timeclock login on a server on a separate domain, do I need to prepare curl in php with any special options when I receive a http response header with X-Frame-Options:SAMEORIGIN?

Here is what I have so far:

//Send tablet keypunches to site
$post_data['user_name'] = 'public';
$post_data['password'] = '1234';
foreach ( $post_data as $key => $value) {
    $post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);
$cookie_jar = tempnam('/tmp','cookie');

$session =  curl_init($website);
curl_setopt($session, CURLOPT_USERAGENT,
  "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($session, CURLOPT_COOKIESESSION, true);
curl_setopt($session, CURLOPT_REFERER,$website);
curl_setopt($session, CURLOPT_HEADER, 1);
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($session, CURLOPT_HTTPGET, 1 );
curl_setopt($session, CURLOPT_URL, $website);
curl_setopt($session, CURLOPT_POST, 1 );
curl_setopt($session, CURLOPT_POSTFIELDS, $poststring );
curl_setopt($session, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
curl_setopt($session, CURLOPT_DNS_CACHE_TIMEOUT, 2 );
curl_setopt($session, CURLOPT_COOKIEJAR, $cookie_jar);
curl_setopt($session, CURLOPT_COOKIEFILE, $cookie_jar );
curl_setopt($session, CURLOPT_FOLLOWLOCATION, true ); 
$output = curl_exec($session);
echo $output;
//Note: If $output contains successful message then return and wait for next staff member to login
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
    • ¥15 onvif+openssl,vs2022编译openssl64
    • ¥15 iOS 自定义输入法-第三方输入法
    • ¥15 很想要一个很好的答案或提示