Hey guys, I have to run on-site URL's through the API for some link shortener. Now, sometimes, the API's fail, or you get RATE_LIMIT_EXCEEDED etc. Now there are many link shortener's out there, all with API's so I should be able to create a pretty fail safe way to creating a short URL link. Using the API functions, I have this: $url = 'http://www.website.com/'.$fetch[id]; $tiny = get_bitly_short_url(''.$url.'','USER_NAME','API KEY'); if ($tiny == "" || $tiny == "RATE_LIMIT_EXCEEDED") { $tiny = TinyURL($url); if ($tiny == "" || $tiny == "RATE_LIMIT_EXCEEDED") { $tiny = $url; } } PHP: But it seems if the bit.ly API fails, and doesn't work its not passing it through the IF statement. They use cURL so is there a delay or something, or any reason why this wouldn't work? Thanks
What response are you expecting from the get_bitly_short_url function? If its not processing the proceeding if statement then its not matching either condition. I.E is it returning false on errors, perhaps?
It either returns a string like this: bit.ly/12431203 or nothing.... It's getting entered in the database as either the bit.ly URL it created or nothing... But I'm passing an if statement to say if it is "" (blank) make a tinyURL instead. But its not jumping to that tinyURL