gpt4 book ai didi

php - 如何通过 php 或 wget 从 Slack 下载图像

转载 作者:可可西里 更新时间:2023-10-31 22:40:14 30 4
gpt4 key购买 nike

我正在尝试通过以下代码从 Slack channel 下载图像,但我只获得了页面的 html 代码。

我是在做傻事,还是他们有办法让事情变得困难?

<?php

copy('https://files.slack.com/files-tmb/T1Q3K1TFB-F6TQMM6AG-baba978dff/image003_480.jpg', 'file.jpeg');

echo '<img src="file.jpeg">';
echo '<hr>';

//Get the file
$content = file_get_contents("https://files.slack.com/files-tmb/T1Q3K1TFB-F6TQMM6AG-baba978dff/image003_480.jpg");

//Store in the filesystem.
$fp = fopen("image.jpg", "w");
fwrite($fp, $content);
fclose($fp);
echo '<img src="image.jpg">';
echo '<hr>';

$url_to_image
= 'https://files.slack.com/files-tmb/T1Q3K1TFB-F6TQMM6AG-baba978dff/image003_480.jpg';

$ch = curl_init($url_to_image);

$my_save_dir = 'images/';
$filename = basename($url_to_image);
$complete_save_loc = $my_save_dir . $filename;

$fp = fopen($complete_save_loc, 'wb');

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
echo '<img src="'.$complete_save_loc.'">';
echo '<hr>';

echo '<hr><img src="https://files.slack.com/files-tmb/T1Q3K1TFB-F6TQMM6AG-baba978dff/image003_480.jpg">';
echo '<hr><img src="https://files.slack.com/files-tmb/T1Q3K1TFB-F6TQMM6AG-baba978dff/image003_360.jpg">';
echo '<hr><img src="https://conversazioniconmario.slack.com/files/U1Q37UCNL/F6TQMM6AG/image003.jpg">';

?>

wget 也被骗了;

wget -nd -r -P /myLocalPath/images  -A jpeg,jpg,bmp,gif,png https://files.slack.com/files-tmb/T1Q3K1TFB-F6TQMM6AG-baba978dff/image003_480.jpg

最佳答案

您也可以通过提供权限下载文件headers :

 wget -d --header="Authorization: Bearer A_VALID_TOKEN" https://files.slack.com/files-pri/T1Q3K1TFB-F6TQMM6AG-baba978dff/download/image003.jpg

关于php - 如何通过 php 或 wget 从 Slack 下载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46132852/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com