跨域PHP

I need some references for cross domain php codes, as well as using javascript in the PHP. Reason why-

I am trying to create a PHP file that can be accessed from a certain site, I am making it so it test a key, as well as what website the user entered when signing up so that if someone tries to steal the script it will not work on their website.

I need to know how to do a cross domain PHP code, then I also don't want users see the Javascript I have written out, only a select bit. So basically it will be like this

$name_of_service({key:"H292H2723H20HC-0239C",options:"option"});

Can anyone explain to me my best bet on how to do this, as well as how to give a code to a user to get access to the PHP file such as...

$.get(php file);

or something of the sort. This is my first time dealing with all of this so I am a newb on the cross domain implementation. The first site does not allow for PHP Access we can only use it from another website server. Best explanations or best website explanation references please.

I appreciate anyones advice and tips. I don't need much more than just how to get it from end user to my server and hide my overall javascript from users, I mean I could encrypt it and then use a compiler though for those of whom know how to decrypt this isn't very helpful either. thank you.

<script src="http://yourwebsite/file.php?key=blah&options=foo"></script>

For future reference:

Wikipedia already gives the answer here. You'll need to add a header Access-Control-Allow-Origin either in a .htaccess file or .php file assuming you are working in an Apache-based environment. Conveniently, PHP provides us the function header for this.

For your script to work with this, you'll also need jQuery to send the respective Origin header to the server. This can be done using jqXhr.setRequestHeader("Origin", location.href);