Calling a PHP script from Drupal retrieves different result than calling it outside Drupal
You really shouldn't use include_once, Instead you should use module_load_include.

After you've done this start putting in Debug code in your include file to make sure it's being loaded. 

Also makes your your include file contains namespaces functions and no variable being used outside a function scope. To avoid any naming collisions that could happend.

Besides that, there really is not much help anyone can provide. A script will work the same way in Drupal as it would when being include in a regular php file.