exfriend / frame-validator

检测URL是否可以被任何网站嵌入iframe中

0.3 2018-05-21 08:16 UTC

This package is auto-updated.

Last update: 2024-09-21 21:11:49 UTC


README

一个用于检查URL并根据服务器响应头判断它们是否可以被任何网站通过iframe嵌入的库。

安装

 composer require exfriend/frame-validator

使用方法

<?php

require 'vendor/autoload.php';
 
if ( \Exfriend\FrameValidator\Validator::make( 'https://example.com' )->supportsIframes() )
{
    echo 'frameable';
}
else
{
    echo 'unframeable';
}
 

覆盖curl选项

<?php
 
require 'vendor/autoload.php';
 
use Exfriend\FrameValidator\Validator;
 
$v = Validator::make( 'https://example.com' )->withCurlOptions( [
    CURLOPT_TIMEOUT => 10,
    CURLOPT_CONNECTTIMEOUT => 5,
] );
 
echo $v->supportsIframes();
 

贡献

欢迎您贡献!