Reputation: 504
We want to host page elements on our site that 3rd party approved vendors can access for use on their site.
In my tests, I'm using JSONP to go cross-domain to send back JSON through PHP. It is working.
My question is two fold:
1.) When I make the client-side AJAX call in jQuery through a .GET, can I check for the http referrer on the server-side? I'm using PHP for testing, but most likely the live version will be in PERL. We're using white-validation, thus there is an array of approved vendors that I will check against. Do I need to use POST to get the referrer or can I pass it through the .GET?
2.) If they are an approved vendor, then I want to return the JSON with the page elements. Because the JSON is a little lengthy, is there a way instead of sending back the encoded JSON, to send back a javascript file name containing the JSON that I can parse against?
In other words, I would return the file name.
Upvotes: 0
Views: 2758
Reputation: 7941
use the $_SERVER('HTTP_REFERER')
to get the referres address in php. Yo dont need to POST
or GET
or anything, enough a simple request.
php can inclde files as content, so you dont need to response a filename, you can response the file. no complication.
header('Content-type: application/json');
include('/files/json/filename.json');
Upvotes: 1