CiviCRM_API3_Exception: '3' is not a valid option for field contribution_page_id
The fact that this works on a local server but not a production server sounds fishy. My guess is that your local server is a different platform and/or php version.

You can likely fix the issue by setting the contribution_page_id to the string "3". 

But I'd suggest you're probably going in the wrong direction for this project - that's a lot of custom code, most of it kind of funky (e.g. the unused bao object, and setting the qfKey), which suggests you've been trying to reverse engineer and/or copy paste stuff. If you simplify your code and only use the api as intended, you'll likely hit fewer oddities like this. I'd also question why you want to set the contribution_page_id anyway, since this isn't getting set via the contribution page, i.e. you're kind of tricking it into an unpredictable state. You'd likely do better categorizing your contributions using other mechanisms (or maybe you don't need to categorize this any further that you already have).