How to get the redirect url from a dynamic link of my app?

171 views
Skip to first unread message

Sanket Kale

unread,
Jan 11, 2020, 12:07:11 PM1/11/20
to Firebase Google Group
Hello, one and all,

I agree this is a bit uncanny, but I need to know the redirect URL of the dynamic link of my own app. The purpose is simple, we have an in-app QR code scanner and upon scanning a QR code containing a dynamic link of our own app, I want to open the corresponding details panel based on the QR-code scanner's result. Now the QR code scanner's result, in this case, will the dynamic link of my app, and I want the redirect URL of the dynamic link to know and open the corresponding panel directly.

I thought of doing a web services call to know the redirect URL using cURL and PHP. Now, this approach works for other URLs but fails for firebase dynamic links somehow. I tried below functions to get the redirect URLs using a PHP web service:

function get_redirect_target($url)
{
 $ch
= curl_init();
 curl_setopt
($ch, CURLOPT_URL, $url);
 curl_setopt
($ch, CURLOPT_HEADER, 1);
 curl_setopt
($ch, CURLOPT_NOBODY, 1);
 curl_setopt
($ch, CURLOPT_RETURNTRANSFER, 1);
 $headers
= curl_exec($ch);
 curl_close
($ch);
 
 
if (preg_match('/^Location: (.+)$/im', $headers, $matches))
 
return trim($matches[1]);
 
 
return $url;
}


function get_redirect_final_target($url)
{
 $ch
= curl_init();
 curl_setopt
($ch, CURLOPT_URL, $url);
 curl_setopt
($ch, CURLOPT_HEADER, 1);
 curl_setopt
($ch, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt
($ch, CURLOPT_RETURNTRANSFER, 1);
 $headers
= curl_exec($ch);
 $target
= curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
 curl_close
($ch);
 
return $target;
}

Now, I scraped through the firebase documentation and couldn't get much help there. I also looked around for some other ways of getting the redirect URL but couldn't get anything to work with the dynamic links created from the firebase. I sincerely hope this is possible.

Could anybody from the firebase team/community please guide me on how to do this? Also, kindly let me know I am missing something here. Guys, please help!

Regards,
Sanket.

Sanket Kale

unread,
Jan 16, 2020, 10:14:36 AM1/16/20
to Firebase Google Group
Is there a way to do this using a firebase API?
Reply all
Reply to author
Forward
0 new messages