get the parent url of iframe in PHP

前端 未结 6 1221
梦毁少年i
梦毁少年i 2021-01-19 12:38

I am creating a widget that would load in a IFrame and users will be able to place the widget on their own website. How would I get the URL of the website that is using the

6条回答
  •  醉酒成梦
    2021-01-19 13:21

    I would use:

    $qStr = explode('?', $_SERVER['HTTP_REFERER']);        
    $t= explode('&', $qStr[1]);
    foreach ($t as $val)
    {
        $a = explode('=', $val);
        $args[$a[0]]=$a[1];
    }
    // to check the arguments
    print_r($args);
    // to check the url
    echo $qStr[0];
    

    $args would contain my security token which would be checked by some hashing against the url

提交回复
热议问题