Reputation: 1744
I'm writing a php script that will fetch data from a given URL and then run a lot of calculations based on that data, and then output it for the user.
The web page in question is a page with an embedded iframe. The iframe contains javascript code that contains the data I need, and unfortunately, the iframe is not hosted on the same domain as the web page. So what I'm trying to do is extract the URL to the iframe from the web page (I can at least do that without hitting cross-domain restrictions), and then pass the URL to the php file, and it will load that URL, and find the information.
This raises a slight problem of the URL having lots of arguments it in already. It's shaped in the form of www.somesite.com/iframe.php?userstring=asfjkl&arg1=654&arg2=132%2C9848%2C698
The problem is that the URL already has arguments, and this will not work well for my php file, which will confuse those arguments being arguments, instead of being part of the URL when I redirect the user to my site's URL of mysite.com/test.php?URL=(string shown above). So now, I'm thinking about a POST request, but sending a POST request will not redirect the users unless I actually have a form. So my question is, if that is a viable idea, to send the URL by creating an invisible form and setting the data to the URL, then submitting it, and if cross domain submission for form is allowed. (I think it is). Any other suggestions?
Upvotes: 2
Views: 820
Reputation: 318558
Simply urlencode()
the URL argument. Then everything works fine.
urlencode('http://www.example.com/blah?x=y&a=123&something=else');
// Returns http%3A%2F%2Fwww.example.com%2Fblah%3Fx%3Dy%26a%3D123%26something%3Delse
Upvotes: 4