URL access without clicking.
Moderator: General Moderators
URL access without clicking.
This sounds simple, but I can't figure it out. I want to verify a security key that's been sent to me from a form.
I can get the key with no problem using $key = $_POST['key']; and I can verify it using the security site's published example using HTML as follows:
Click to <a href="https://www.security.com/<? echo $key ?>" target="_blank" >VERIFY</a>
and clicking the link. This spawns another page containing the returned data.
But how do I do this in PHP. In other words I don't want to have to click a link, I want to just hit the URL and get a response.
Opening the link and trying to read it doesn't work probably due to the security. Is there any way to emulate clicking that link?
Thanks.
I can get the key with no problem using $key = $_POST['key']; and I can verify it using the security site's published example using HTML as follows:
Click to <a href="https://www.security.com/<? echo $key ?>" target="_blank" >VERIFY</a>
and clicking the link. This spawns another page containing the returned data.
But how do I do this in PHP. In other words I don't want to have to click a link, I want to just hit the URL and get a response.
Opening the link and trying to read it doesn't work probably due to the security. Is there any way to emulate clicking that link?
Thanks.
Code: Select all
echo file_get_contents('https://www.security.com/'.$key);Right, like I said it complains...
Warning: file_get_contents() [function.file-get-contents]: Unable to access https://www.security.com/171717171717171717171717 in /myaccount/public_html/rlg0613/authenticate/result2.php on line 43
Warning: file_get_contents(https://www.security.com/171717171717171717171717) [function.file-get-contents]: failed to open stream: No such file or directory in /myaccount/public_html/rlg0613/authenticate/result2.php on line 43
Warning: file_get_contents() [function.file-get-contents]: Unable to access https://www.security.com/171717171717171717171717 in /myaccount/public_html/rlg0613/authenticate/result2.php on line 43
Warning: file_get_contents(https://www.security.com/171717171717171717171717) [function.file-get-contents]: failed to open stream: No such file or directory in /myaccount/public_html/rlg0613/authenticate/result2.php on line 43
Re: URL access without clicking.
I'm going to make a guess that you left out a ? in that url. The way you showed it, the $key would have to be a subdirectory at http://www.security.com, which seems unlikely. More likely is that it should be a GET parameter, and if so, it should look like:rlg0613 wrote:I can get the key with no problem using $key = $_POST['key']; and I can verify it using the security site's published example using HTML as follows:
Click to <a href="https://www.security.com/<? echo $key ?>" target="_blank" >VERIFY</a>
and clicking the link. This spawns another page containing the returned data.
Code: Select all
Click to <a href="https://www.security.com/?<? echo $key ?>" target="_blank" >VERIFY</a>So here's how I got part of the solution...
In lieu of the click-able link in HTML I added the following in PHP. I already had the $key that I needed to verify.
header("Location: https://www.security.com/".$key);
That's the last thing I do and no HTML output had been issued prior to that line. It works fine for calling the authentication site and the site responds with a text content page verifying the $key value. The problem is I'm still not in control. Is there a header() line that I can send out to request http://www.security.com to call me instead of just blasting out a text page?
Thanks.
In lieu of the click-able link in HTML I added the following in PHP. I already had the $key that I needed to verify.
header("Location: https://www.security.com/".$key);
That's the last thing I do and no HTML output had been issued prior to that line. It works fine for calling the authentication site and the site responds with a text content page verifying the $key value. The problem is I'm still not in control. Is there a header() line that I can send out to request http://www.security.com to call me instead of just blasting out a text page?
Thanks.
Solution...
The solution works great...
The $key value was previously discussed.
The result come back in string form. You just need to handle it.
The $key value was previously discussed.
Code: Select all
$addr = gethostbyname('https://www.security.com/');
$verf_loc = $addr . $key;
$cURL_handle = curl_init($verf_loc);
curl_setopt($cURL_handle, CURLOPT_RETURNTRANSFER, 1);
$auth_verf = trim(curl_exec($cURL_handle));