Hey Jan,
Look at the $post_data variable:
$post_data = array( 'method' => 'limelm.pkey.generate', 'version_id' => $version_id, 'num_keys' => 1, 'num_acts' => $quantity, 'email' => $email, 'api_key' => $api_key, 'nojsoncallback' => 1, 'format' => 'json');
Specifically the 'num_acts' element. You might want to replace that element with:
'num_acts' => $quantity * 2,