Get youtube redirected link from short link

When I click on the 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 do I get this redirected link programmatically from an Android application?

I want to finally get the youtube video id.

+3


source to share


1 answer


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

you will get http status 302 (redirect):



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.

+1


source







All Articles