【发布时间】:2021-10-25 18:39:55
【问题描述】:
我正在使用来自 oauth 库的 hybridauth-3.7.1。 https://github.com/hybridauth/hybridauth/releases
图书馆完美运行,所以我有以下内容:
<?php
require_once 'hybridauth-3.7.1/vendor/autoload.php';
$config = [
'callback' => 'my_callback_url',
'keys' => [
'id' => 'my_app_id',
'secret' => 'my_secret'
],
];
$adapter = new Hybridauth\Provider\Reddit( $config );
$adapter->authenticate();
$userProfile = $adapter->getUserProfile();
$photo = $userProfile->photoURL;
如果我回显 $photo 我得到: https://styles.redditmedia.com/t5_55fo22/styles/profileIcon_bblqmk8klas71.png?width=256&height=256&crop=256:256,smart&s=30a3bb6af945eadeaddb40271d2c0161ca82768d
现在如果我尝试:
imagecreatefrompng($photo);
我的日志返回:
imagecreatefrompng( https://styles.redditmedia.com/t5_55fo22/styles/profileIcon_bblqmk8klas71.png?width=256&amp;height=256&amp;crop=256:256,smart&amp;s=30a3bb6af945eadeaddb40271d2c0161ca82768d ): failed`
所以 url 在 echo 中正确返回,但从日志中可以看出 imagecreatefrompng 添加了一个奇怪的 &
我也试过
imagecreatefrompng(urldecode($photo));
和
$decoded_photo = urldecode($photo);
imagecreatefrompng($decoded_photo);
两者都返回相同的上述错误日志。
但是,如果我在其中手动输入 url 就可以了。
imagecreatefrompng( 'https://styles.redditmedia.com/t5_55fo22/styles/profileIcon_bblqmk8klas71.png?width=256&height=256&crop=256:256,smart&s=30a3bb6af945eadeaddb40271d2c0161ca82768d' );
如何让返回的图片 url 与 imagecreatefrompng 一起使用?
【问题讨论】: