The output of http_build_query is dependant on the php config value arg_separator.output unless the arg separator is specified in the function call.

So

$query = http_build_query($data);

should be

$query = http_build_query($data,'','&');

This bit me when deploying my app to Pantheon. Their php is set up with arg_separator.output = '&'. This broke my stackla service requests.