Page 1 of 1

URL access without clicking.

Posted: Sat Aug 25, 2007 10:46 am
by rlg0613
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.

Posted: Sat Aug 25, 2007 10:50 am
by miro_igov

Code: Select all

echo file_get_contents('https://www.security.com/'.$key);

Posted: Sat Aug 25, 2007 11:03 am
by rlg0613
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

Re: URL access without clicking.

Posted: Sat Aug 25, 2007 12:15 pm
by califdon
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.
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:

Code: Select all

Click to <a href="https://www.security.com/?<? echo $key ?>" target="_blank" >VERIFY</a>

Posted: Sat Aug 25, 2007 12:23 pm
by rlg0613
Actually, no the clickable link works every time just the way it is.

Posted: Sat Aug 25, 2007 3:37 pm
by feyd
I would suspect your host does not have SSL enabled/installed for PHP to use.

Posted: Mon Aug 27, 2007 1:45 pm
by rlg0613
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.

Posted: Mon Aug 27, 2007 3:52 pm
by feyd
Headers are given to the requesting agent. So, no.

Solution...

Posted: Wed Aug 29, 2007 11:14 am
by rlg0613
The solution works great...

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));
The result come back in string form. You just need to handle it.