If the code works on one platform but not on live, it's most likely that you need to request outgoing network access from the live server; it's not unusual for this to be disabled.