使用file_get_contents或curl从我的域之外的源嵌入html

发布于 2024-12-27 15:45:05 字数 1107 浏览 0 评论 0原文

我们正在开发一个网络应用程序,使最终用户能够在其网页上放置一些代码,以便任何访问其页面的人都会在浏览器窗口边缘看到一个弹出的小按钮。单击后,它会打开一个小面板,他们可以在其中输入电话号码,以便网站所有者给他们回电。

我遇到了安全问题。我正在尝试使用服务器端包含将按钮放置在客户端的网站上。但是,由于此包含的网站与客户网站位于不同的域中,因此不允许这样做。

我尝试过从网上论坛获得的这两种方法,但都不适合我。

  1. 使用file_get_contents处理程序,如下所示;

    <前><代码>$includeFile = file_get_contents("http://bizzocall.com/subdomains/dev/httpdocs/slideouttesttopDATA.php"); 回声 $includeFile;

错误无法打开流:HTTP 请求失败! HTTP/1.1 404 未找到。

  1. 使用curl,如下所示:

    函数curl($url){
        $ch=curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        $数据=curl_exec($ch);
        卷曲_关闭($ ch);
        返回$数据;
    }
    
    
        $feed = 'http://bizzocall.com/subdomains/dev/httpdocs/slideouttesttopDATA.php';
        $bizzobtn = 卷曲($feed);
        回声 $bizzobtn;
    

这也不起作用。

错误在此服务器上找不到请求的 URL /subdomains/dev/httpdocs/slideouttesttopDATA.php。

这看起来像是截断了 bizzocall.com/ 的网址。如果我知道如何正确编写这段代码,也许这会起作用。

欢迎任何帮助!

We are developing a web app that enables the end user to place a bit of code on their webpage, so that anyone who visits their page will see a little pop up button on the edge of the browser window. When clicked, it opens a small panel where they can enter a telephone number for the website owner to call them back.

I am running up against a security issue. I am attempting to use server side include to place the button on the client's website. However, because this included site is on a different domain than the client's website, it is not allowed.

I have tried these two methods that I got from online forums, neither of which worked for me.

  1. Use the file_get_contents handler, like this;

    $includeFile =   
    file_get_contents("http://bizzocall.com/subdomains/dev/httpdocs/slideouttesttopDATA.php");
    echo $includeFile;
    

ERROR failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found.

  1. Use curl, like this:

    function curl($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }
    
    
        $feed = 'http://bizzocall.com/subdomains/dev/httpdocs/slideouttesttopDATA.php';
        $bizzobtn = curl($feed);
        echo $bizzobtn;
    

This didn't work either.

ERROR The requested URL /subdomains/dev/httpdocs/slideouttesttopDATA.php was not found on this server.

This looks like its truncating the bizzocall.com/ off of the url. Perhaps If I knew how to write this chunk of code correctly,this would work.

Any help here would be welcome!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

灯下孤影 2025-01-03 15:45:05

404 错误来自远程服务器,而不是您自己的。尝试访问该 URL - 您将得到相同的 404。

当我访问 http:// /bizzocall.com/subdomains/dev/httpdocs/slideouttesttopDATA.php,我得到以下内容:

在此处输入图像描述

因此,问题在于您使用了错误的 URL。不过,你的代码是健全的。

The 404 error is coming from the remote server, not your own. Try to reach that URL - You'll get the same 404.

When I visit http://bizzocall.com/subdomains/dev/httpdocs/slideouttesttopDATA.php, I get the following:

enter image description here

Therefore, the issue is that you're using the wrong URL. Your code is sound, however.

谁把谁当真 2025-01-03 15:45:05

您的curl 代码工作正常,问题是找不到URL。
将其放入浏览器中即可查看。

如果您拥有 bizzocall.com,您需要将 SlideouttesttopDATA.php 放在可通过 Web 访问的区域中,然后您就可以使用curl 访问它。

Your curl code is working fine, the problem is the URL isn't found.
Put it in your browser to see.

If you own bizzocall.com, you'll want to put slideouttesttopDATA.php in a web accessible area, then you'll be able to access it with curl.

西瓜 2025-01-03 15:45:05

使用浏览器访问您的链接,您会发现您尝试请求的资源显然不存在。有关 HTTP 404 状态代码的更多信息,请访问:http://en.wikipedia.org/wiki/HTTP_404< /a>.

Visit your link a browser and you'll see that the resource you're trying to request clearly doesn't exist. More info on the HTTP 404 status code found here: http://en.wikipedia.org/wiki/HTTP_404.

花开半夏魅人心 2025-01-03 15:45:05

也许它应该是 http://dev.bizzocall.com/slideouttesttopDATA.php 就像你的网址一样粘贴到浏览器中时不起作用...

Perhaps it should be http://dev.bizzocall.com/slideouttesttopDATA.php as your URL does not work when pasted into a browser...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文