要在单独域的服务器上检索成功的时钟登录,当我收到带有 X-Frame-Options:SAMEORIGIN 的 http 响应标头时,是否需要在 php 中准备 curl 以及任何特殊选项?
这是我到目前为止所拥有的:
//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