I have a function to translate the current text string using the Free Bing API. I just want to make sure that something will not succeed or that something is happening with the application identifier or if I click on the prompts, I don’t want to show a big error.
The code I have now is:
$translate_feed = file_get_contents('http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=' . BING_APPID . '&text=' . urlencode($text) . '&from=en&to=' . $to_lan . ''); $translate = simplexml_load_string($translate_feed); return $translate[0];
I want something to happen if something doesn’t work, so if I add another character to the URL to make it invalid, I want it to just return $text , at least that- that shows.
Thanks!
source share