0

I'm trying to replace my Google URL Shortener function with Dynamic Links. I need to do a REST POST with data but I can not find the app-code I am supposed to use.

The documentation for Firebase Dynamic Links does not seem to explain where I am supposed to find my app-code. The example on https://firebase.google.com/docs/dynamic-links/create-manually

Is Dynamic Link a good replacement for a standard URL Shortener or should I be looking at other service providers like bit.ly?

andrebruton
  • 2,268
  • 4
  • 29
  • 36

2 Answers2

2

Go to this page: Firebase setting. You might be prompted to select your project, there in grey you will see the app-code.You will see the Project-ID which is the same as your app-code.

On your second question: I'd look into other service providers like Bitly or Ow.ly

Arazu
  • 421
  • 2
  • 5
  • 15
0

Here is the php code for the updated function that uses bit.ly now...

function shortUrl($longUrl) {

  $oathToken = '<your_app_oath_token>';

  /* returns the shortened url */
  $connectURL = 'https://api-ssl.bitly.com/v3/shorten?access_token=' . $oathToken . '&longUrl=' . urlencode($longUrl);

  $ch = curl_init();
  $timeout = 5;
  curl_setopt($ch, CURLOPT_URL, $connectURL);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  curl_setopt($ch, CURLOPT_POST, 1);
  $data = curl_exec($ch);
  curl_close($ch);

  $short_url = json_decode($data);

  if(isset($short_url->error)){
    throw new Exception($short_url->error->message);
  }

  $msg = $short_url->data->url;

  return $msg;

}
andrebruton
  • 2,268
  • 4
  • 29
  • 36