通过https和php获取图像 [英] Get image via https and php

查看:128
本文介绍了通过https和php获取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hy!

我试图在php中获取每个https的图像。

I'm trying to get an image per https in php.

我是什么我发现这个代码类似于向我显示宽度正确但高度错误的空白图片:

What I've found is something like this code which shows me an blank image with correct width but wrong height:

    function getSslPage($url) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_REFERER, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }

    echo getSslPage("https://www...");

我很感激任何帮助。 :)

I'm grateful for any help. :)

推荐答案

这应该在任何情况下都可以这样做:

This should do it in any situation:

$ch = curl_init ($source_url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$rawdata=curl_exec($ch);
curl_close ($ch);

$fp = fopen($local_file,'w');
fwrite($fp, $rawdata);
fclose($fp)

这篇关于通过https和php获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆