URL access without clicking.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
rlg0613
Forum Newbie
Posts: 12
Joined: Sat Aug 25, 2007 10:15 am

URL access without clicking.

Post 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.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Code: Select all

echo file_get_contents('https://www.security.com/'.$key);
User avatar
rlg0613
Forum Newbie
Posts: 12
Joined: Sat Aug 25, 2007 10:15 am

Post 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
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: URL access without clicking.

Post 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>
User avatar
rlg0613
Forum Newbie
Posts: 12
Joined: Sat Aug 25, 2007 10:15 am

Post by rlg0613 »

Actually, no the clickable link works every time just the way it is.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I would suspect your host does not have SSL enabled/installed for PHP to use.
User avatar
rlg0613
Forum Newbie
Posts: 12
Joined: Sat Aug 25, 2007 10:15 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Headers are given to the requesting agent. So, no.
User avatar
rlg0613
Forum Newbie
Posts: 12
Joined: Sat Aug 25, 2007 10:15 am

Solution...

Post 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.
Post Reply