How to parse an https URL that redirects to another URL


Giardolio

I am trying to parse this URL

https://graph.facebook.com/4/picture?width=378&height=378

But it redirects me to another link:

https://zn.ak.fbcdn.net/profile.ak/hprofile-ak-xfp1/v/t1.0-1/p480x480/10390028_10102210419817761_5871103530921178170_n.jpg?oh=9d44ae6370a6481a6e4e5c42d7850e284e26fa2673a328a e286e2673 _

So the problem is that I want to implement the code that uses the first link, and when it redirects to the second link, resolves the second link, I need to get the content from the second URL, what is the best practice?

Thanks in advance for your help

feather art

Using CURL:

$url = 'https://graph.facebook.com/4/picture?width=378&height=378';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow the redirects
curl_setopt($ch, CURLOPT_HEADER, false); // no needs to pass the headers to the data stream
curl_setopt($ch, CURLOPT_NOBODY, true); // get the resource without a body
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // accept any server certificate
curl_exec($ch);

// get the last used URL
$lastUrl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

curl_close($ch);

echo $lastUrl;

Related


Get the URL another URL redirects to

eh I'm trying to get a hold URL to redirect to another URL . For example, I go to http://www.example.com/redirect . Now this page redirects me to http://www.some-other-domain.com/?language=english . How to just use http://www.example.com/redirect URL and get h

How to check if a url redirects to another url using Python

Josh Josh I want to check if the destination url is redirected after the visit. I thought I could do something like this: req = urllib2.Request(url=url, headers=headers) resp = urllib2.urlopen(req, timeout=3) code = resp.code if code == '200': # valid else: #

How to check if a url redirects to another url using Python

Josh Josh I want to check if the destination url is redirected after the visit. I thought I could do something like this: req = urllib2.Request(url=url, headers=headers) resp = urllib2.urlopen(req, timeout=3) code = resp.code if code == '200': # valid else: #

How to check if a url redirects to another url using Python

Josh Josh I want to check if the destination url is redirected after the visit. I thought I could do something like this: req = urllib2.Request(url=url, headers=headers) resp = urllib2.urlopen(req, timeout=3) code = resp.code if code == '200': # valid else: #

How to check if a url redirects to another url using Python

Josh Josh I want to check if the destination url is redirected after the visit. I thought I could do something like this: req = urllib2.Request(url=url, headers=headers) resp = urllib2.urlopen(req, timeout=3) code = resp.code if code == '200': # valid else: #

How to check if a url redirects to another url using Python

Josh Josh I want to check if the destination url is redirected after the visit. I thought I could do something like this: req = urllib2.Request(url=url, headers=headers) resp = urllib2.urlopen(req, timeout=3) code = resp.code if code == '200': # valid else: #

How to check if a url redirects to another url using Python

Josh Josh I want to check if the destination url is redirected after the visit. I thought I could do something like this: req = urllib2.Request(url=url, headers=headers) resp = urllib2.urlopen(req, timeout=3) code = resp.code if code == '200': # valid else: #

OnClick redirects user to another url

supply I want to change the bg colors in the following order: [black, white, red, green, blue] <body style="background-color:black"> <script type="text/javascript"> function test() { var bg = document.bgColor; var e = docum

Multiple parameter URL redirects to another lovely URL

Cumatru Cosu I want to redirect via htaccess: test.mydomain.com/articles_main.php?post=POSTTILE&name=&email=To : mydomain.com/POSTTILE Thanks a lot for your help, I've been struggling with this for a long time, please help. EDIT: I've tested a lot of things, b

Multiple parameter URL redirects to another lovely URL

Cumatru Cosu I want to redirect via htaccess: test.mydomain.com/articles_main.php?post=POSTTILE&name=&email=To : mydomain.com/POSTTILE Thanks a lot for your help, I've been struggling with this for a long time, please help. EDIT: I've tested a lot of things, b

Multiple parameter URL redirects to another lovely URL

Cumatru Cosu I want to redirect via htaccess: test.mydomain.com/articles_main.php?post=POSTTILE&name=&email=To : mydomain.com/POSTTILE Thanks a lot for your help, I've been struggling with this for a long time, please help. EDIT: I've tested a lot of things, b

keycloak redirects url to http instead of https

Rahul I have a keycloak setup behind an SSL terminating nginx proxy. When I try to access an application secured with keycloak, keycloak generates a url like this: https://keycloak.mydomain.com/auth/realms/AdfsDemo/protocol/openid-connect/auth?client_id=adfs&r

Magento HTTPS on all websites: URL redirects to homepage

username I'm using Magento 1.9.1 and I'm having issues with SSL. I want to have https on all sites, on all pages. The site is in the subfolder /shop/. When I set the base url (not secure) on the https version, it works, but I have a problem: when I visit the U

Magento HTTPS on all websites: URL redirects to homepage

username I'm using Magento 1.9.1 and I'm having issues with SSL. I want to use https on all sites, on all pages. The site is in the subfolder /shop/. When I set the base URL (not secure) on the https version, it works, but I have a problem: when I visit the UR

keycloak redirects url to http instead of https

Rahul I have a keycloak setup behind an SSL terminating nginx proxy. When I try to access an application secured with keycloak, keycloak generates a url like this: https://keycloak.mydomain.com/auth/realms/AdfsDemo/protocol/openid-connect/auth?client_id=adfs&r

Magento HTTPS on all websites: URL redirects to homepage

username I'm using Magento 1.9.1 and I'm having issues with SSL. I want to use https on all sites, on all pages. The site is in the subfolder /shop/. When I set the base URL (not secure) on the https version, it works, but I have a problem: when I visit the UR

.htaccess redirects to https except admin url

Simon Kupchan I want to redirect all frontend requests to protected site https and all admin/backend urls should remain unprotected http. Also, I use Cloudflare CDN. My rewrite rules don't work, all queries go to https. RewriteCond %{HTTPS} off RewriteCond %{H

How to track URL redirects in browser?

Prachamp When I type into my http://example.com/load/browser and press ENTER, the site redirects me to , http://example.com/load/1/from there , http://example.com/load/2/and I finally land http://example.com/load/3/. These redirects are happening on the websit

How to track URL redirects in browser?

Prachamp When I type into my http://example.com/load/browser and press ENTER, the site redirects me to , http://example.com/load/1/from there , http://example.com/load/2/and I finally land http://example.com/load/3/. These redirects are happening on the websit

How to get the URL someone redirects to

Nicola So let me say the owner of the awp.rs domain. I made a simple redirect script so anyone visiting the domain awp.rs will be redirected to say: by.nies.host Now, in by.nies.host, I want to print awp.rs because I redirected to the site by visiting awp.rs D

CakePHP redirects to another URL but with the same controller

how I'm starting with cake php and mvc and php framework so I'm a bit confused. As I can see, cakephp allows me to route URLs, so I have a Users controller for admin and I would like to know how to redirect it to /admin/users/* instead of /users/*. I have trie

Error: My controller redirects me to another URL

Wahib Please can anyone tell me why I have been automatically redirected to another localhost:8080/login when I try to connect to localhost:8080/users/get . ****There is only one controller in my app**** all. @RestController @RequestMapping(path = "users") p

Error: My controller redirects me to another URL

Wahib Please can anyone tell me why I have been automatically redirected to another localhost:8080/login when I try to connect to localhost:8080/users/get . ****There is only one controller in my app**** all. @RestController @RequestMapping(path = "users") p

CakePHP redirects to another URL but with the same controller

how I'm starting with cake php and mvc and php framework so I'm a bit confused. As I can see, cakephp allows me to route URLs, so I have a Users controller for admin and I would like to know how to redirect it to /admin/users/* instead of /users/*. I have trie

Error: My controller redirects me to another URL

Wahib Please can anyone tell me why I have been automatically redirected to another localhost:8080/login when I try to connect to localhost:8080/users/get . ****There is only one controller in my app**** all. @RestController @RequestMapping(path = "users") p

Error: My controller redirects me to another URL

Wahib Please can anyone tell me why I have been automatically redirected to another localhost:8080/login when I try to connect to localhost:8080/users/get . ****There is only one controller in my app**** all. @RestController @RequestMapping(path = "users") p

Error: My controller redirects me to another URL

Wahib Please can anyone tell me why I have been automatically redirected to another localhost:8080/login when I try to connect to localhost:8080/users/get . ****There is only one controller in my app**** all. @RestController @RequestMapping(path = "users") p

denyAll() redirects to login url but i need another url

Picture of Rafael Ruiz Tabares This code correctly blocks every request done on XHTML, but I want to redirect the request to a url like "/spring/denied" instead of "/spring/login" set on the method formLogic() http .formLogin() .log