开发者

PHP mirror a webpage

I am trying to create a mirror of a weather widget which I use for a website. Presently, it is used on an HTTPS page, but widget server does not support that (and IE throws a tantrum with dialogs because the widget is not HTTPS)

To solve this, I would like to do is mirror the page in HTTPS to silence the security warnings. I would normally use file_get_contents() for this, however the page contains images which makes it a little more complicated.

**Also as a side note, there isn't any ads on my website or theirs, so there is开发者_StackOverflow no revenue stealing


Use CURL to grab a page's content (images and all). You can put this in a file, then use that URL in place of where you'd use the widget's URL:

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

See the docs: http://www.php.net/manual/en/function.curl-exec.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜