what kind of response is this?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

what kind of response is this?

Post by JellyFish »

HTTP/1.0 302 Moved Temporarily Location
What kind of HTTP response is this? I googled it, and I don't understand what it means? I sent a request using the POST method.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Hmm... It's pretty much straight forward, isn't it?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Oren wrote:Hmm... It's pretty much straight forward, isn't it?
I'm sorry for being dubious, but I'm not understanding to my fullest extent. Please explain why it's straight forward, and more importantly: what it's straight forward to.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

JellyFish wrote:Please explain why it's straight forward, and more importantly: what it's straight forward to.
Because it says: "Moved Temporarily Location" :P
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Oren wrote:
JellyFish wrote:Please explain why it's straight forward, and more importantly: what it's straight forward to.
Because it says: "Moved Temporarily Location" :P
What's "Moved Temporarily"? The file I made request to? If so, why would that file have moved? Or does this mean that the page that I made the request to has redirected to another page?

EDIT: To be more specific, what kind of response is this:
HTTP/1.0 302 Moved Temporarily Location: https://www.linkpointcentral.com/lpc/servlet/lppay X-Cache: MISS from wc04.inet.mesa1.secureserver.net Connection: close 168
?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Basically 302 is similar to 404 in that the file you requested isn't there. 302 means that the file has been moved temporarily.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

pickle wrote:Basically 302 is similar to 404 in that the file you requested isn't there. 302 means that the file has been moved temporarily.
Okay, why wouldn't it be there?

Here's my full on script metropolis:

http.php

Code: Select all

<?php
	function HttpRequest($address, $data)
	{
		$url = parse_url($address);
		
		while (list($key, $value) = each($data))
		{
			$dataToPost .= "$key=$value&";
		}
		$dataToPost = rtrim($dataToPost, "&");
		
		$request = 	"POST ".$url['path']." HTTP/1.1\r\n"
				. "Host: ".$url['host']."\r\n"
				. "Content-Type: application/x-www-form-urlencoded;\r\n"
				. "Content-Length: ".strlen($dataToPost)."\r\n"
				. "\r\n"
				. $dataToPost;
		
		$socket = @fsockopen($url['host'], 80, $errno, $errstr) or die("Error: unable to open a socket connection with ".$url['host']."\n $errno: $errstr");
		fwrite($socket, $request);
		
		// Response
		$response = '';
		while (!feof($socket)) {
		    $response .= fpassthru($socket);
		}
		fclose($socket);
		
		return $response;
	}
?>
index.php

Code: Select all

$myorder["host"]       = "secure.linkpt.net";
			$myorder["port"]       = "1129";
			$myorder["keyfile"]    = "/home/content/******html/lpAPI/cert.pem"; # Change this to the name and location of your certificate file 
			$myorder["storename"] = "1085600";        # Change this to your store number 
		
			$myorder["txntype"]    = "SALE";
			$myorder["chargetotal"]  = "2.95";
			$myorder["cardnumber"]   = $_POST['ccard_num'];
			$myorder["expmonth"] = $_POST['ccard_exp_month'];
			$myorder["expyear"]  = $_POST['ccard_exp_year'];
			$myorder["cvm"]      = $_POST['CID'];   # Required for AVS. If not provided, transactions will downgrade.
			$myorder["zip"]          = $_POST['zip']; # Required for AVS. If not provided, transactions will downgrade.
			$myorder["debugging"]    = "true";  # for development only - not intended for production use
			
			# periodic fields
		/*	$myorder["action"]       = "SUBMIT";
			$myorder["installments"] = "1";
			$myorder["threshold"]    = "3";
			$myorder["startdate"]    = "immediate";
			$myorder["periodicity"]  = "monthly"; */
			
			# Send transaction. Use one of two possible methods  #
			$transaction = HttpRequest("https://www.linkpointcentral.com/lpc/servlet/lppay", $myorder);				//$lpObj->curl_process($myorder) or die("Fialed at sending the transaction using curl_process method!");  # use curl methods
			
			exit($transaction);
So what I do is build up an array of data to post to somewhere. I call the HttpRequest function and pass the URL of where to post and the array to post.

In the HttpRequest function definition I take the $address parameter and break it up into url parts with the parse_url function. I also break the $data parameter into parts and format it in a http request data string(this I know works).

Maybe the problem is in the $address parameter handling???

Thank you so much for the post. You don't know how much I appreciate them.
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Post by Citizen »

JellyFish,

A 302 usually means that someone places a bit of code (either in php or on the .htaccess file, etc) that is redirect you another page or report an error. Webmasters use this to direct users and search engines to the correct page.

For instance, if I temporarily renamed a file, i'd use a 302 to not waste any incoming links for SEO purposes.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Citizen wrote:JellyFish,

A 302 usually means that someone places a bit of code (either in php or on the .htaccess file, etc) that is redirect you another page or report an error. Webmasters use this to direct users and search engines to the correct page.

For instance, if I temporarily renamed a file, i'd use a 302 to not waste any incoming links for SEO purposes.
So 302 code means that the page that I sent the request to has redirected to another page? If that's the case then why wasn't the response the contents of the page it redirected to?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Why do you have three threads for the same piece of code?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

feyd wrote:Why do you have three threads for the same piece of code?
It started out as three different questions. Sorry, I didn't have my head on straight.
Post Reply