Refactored scripts will be packaged with the upcoming RC5 release.
For perl script - replace
$ua->agent($config{'key'});
With
$ua->agent('osTicket');
$ua->default_header('X-API-Key' => $config{'key'});
And for the PHP script - simply add the following line to curl setup options.
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Expect:', 'X-API-Key: '.$config));