1
I’m trying to get the url that is displayed (switched) when accessing a link as for example on instagram https://www.instagram.com/p/B9MjyquAfkE/media/? size=l, the link generated after the click, comes from the instagram api, and as this same link generated has expiration time, there is no way to use it for long. Is there any way via php, to catch it without showing the page itself from the link? I tried to use Curl but could not get the result.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '"'.$dadosItemInstagram['imagem'].'"');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$ret = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
The $dadosItemInstagram['image'] array contains the link. I’ve been reading a lot before coming here, and so I understood instagram from an account authorization to access their api, for example to display images or videos on websites, except that the link has a certain duration so I’m stuck in this part, the solution I found was to add the /media/?size=l
, at the end of the link, so I know if it’s the best too.
It worked very well, but I could only play by putting a link in
curl_setopt($ch, CURLOPT_URL, "(um_link_aqui)");
, if I put a variable that contains the link it is not right, I do not know if it is possible too, has this possibility?– Vileza
It is also possible to return only the redirected url?
– Vileza
Yes, this is already being done with the function
curl_getinfo
:$urlRedirecionada = $info['url'];
– TiagoA