How do you broadcast a transaction programatically? What is the best way to broadcast a transaction to the network programatically? I know that blockchain.info has /pushtx but I'm pretty sure it rejects XHR requests from external sources because of CORS.
You should not use an online service for broadcasting transaction. This online-service would have full control (censor?) over your transaction. The service could analyze your data behavior and/or decide to not broadcast your transaction regarding some rules.

Wladimir van der Laan (current bitcoin-core project maintainer) has written a neat tool: https://github.com/laanwj/bitcoin-submittx

Another option would be to install bitcoin-core, sync (takes serval hours and around 40GB traffic) and use RPC sendrawtransaction.