How to convert an image link to an image in PHP
There is such an API code for requesting tweets from Twitter:
<?php
require_once('TwitterAPIExchange.php');
$settings = array(
'oauth_access_token' => "ххх",
'oauth_access_token_secret' => "ххх",
'consumer_key' => "ххх",
'consumer_secret' => "ххх"
);
$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
$requestMethod = "GET";
if (isset($_GET['user'])) {$user = $_GET['user'];} else {$user = "ххх";}
if (isset($_GET['count'])) {$count = $_GET['count'];} else {$count = 3;}
$getfield = "?screen_name=$user&count=$count";
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(),$assoc = TRUE);
if(array_key_exists("errors", $string)) {echo "<h3>Sorry, there was a problem.</h3><p>Twitter returned the following error message:</p><p><em>".$string[errors][0]["message"]."</em></p>";exit();}
foreach($string as $items)
{
echo '<a href="/" target="blank"><div class="tw">
<div class="tw_title">'. $items['user']['name'].'</div>
<div class="tw_date">'. $items['user']['screen_name']. '</div>'. ' > '.
'<div class="tw_date">'. $items['created_at']."<br />".'</div></div></a>';
echo '<div class="tw_text"><a href="/" target="blank">'. $items['text']."<br />".'</a></div>';
echo '<div class="tw_pad">'. $items['user']['profile_image_url']."<br />".'</div>';
}
?>
There is a code for getting a link to the image:
echo '<div class="tw_pad">'. $items['user']['profile_image_url']."<br />".'</div>';
I get this answer:
http://pbs.twimg.com/profile_images/1226855970246201345/F7jRYOAf_normal.png
So you need to show not a link to the image but the image itself. Thank you in advance!
1
Author: Viachaslau, 2020-04-03