Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get youtube redirected link from short link

When i click url:

https://youtu.be/rCiqxFuRi6o?rel=0&wmode=transparent

It redirects to

https://www.youtube.com/watch?v=rCiqxFuRi6o&feature=youtu.be&rel=0&wmode=transparent

How to get programatically from android app this redirected link?

I want finally to get youtube video id.


1 Answers

when you connect to https://youtu.be/rCiqxFuRi6o?rel=0&wmode=transparent

you'll get http 302 status (redirection) :

HTTP/1.1 302 Found
Date: Thu, 07 May 2015 14:25:38 GMT
Server: gwiseguy/2.0
Location: https://www.youtube.com/watch?v=rCiqxFuRi6o&feature=youtu.be
Content-Length: 0
Content-Type: text/html
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN

so you just need to read the Location header from the http response header.

like image 186
Yosef-at-Panaya Avatar answered Nov 29 '25 06:11

Yosef-at-Panaya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!