2

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?

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

1 Comment

No, it will already be decoded as the urlencode is required for it to be a proper query string argument and thus it's decoded automatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.