Loop / CURL Help

Hey Guys,

I need a little help with this. I have a CURL function set up and I’m trying to collect multiple order numbers from a textarea and run them through the curl to get results for each order.

I’m not sure how the loop should be formatted to return / contain the results for each order.

I need $get_token to contain the results for each order number. Would be ideal if I could make it an array such as:
Order
–Token
Order
–Token
Order
–Token

Any help on this would be appreciated!

[php]function downloadUrl($Url, $ch){
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_REFERER, “https://website here”);
curl_setopt($ch, CURLOPT_USERAGENT, “MozillaXYZ/1.0”);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$output = curl_exec($ch);

return $output;

}

function login($user,$pass){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://website here login’); //login URL
curl_setopt ($ch, CURLOPT_POST, 1);
$postData="
node=security
&static_password=$pass
&authorize=Proceed
&mac_admin_name=$user
&static_password_text=$pass";
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt ($ch, CURLOPT_COOKIEJAR, ‘cookie.txt’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$store = curl_exec ($ch);

return $ch;

}

function getOrder($order_n,$ch){

$order_url = 	downloadUrl("Website here", $ch);


		$stripped_html =  str_replace("\t", '', $order_url);
	
				return $stripped_html;

}

if ($_POST['submit'] == "Search Orders"){

	$order_n = trim($_POST['orders']);


		if ($order_n == ""){

			$err = "<font color=\"red\"><i>Error: You must provide an order number!</i></font><br />";

		}else{


			$lines = explode("\n", $order_n);

				foreach( $lines as $line ){

						

				$user = "username";
				$pass = "password";

					$ch=login($user,$pass);

						$do_order = getOrder($line,$ch);


				$token = explode('&quot;EC-', $do_order);
				$token = explode('&quot;', $token[1]);
				$token = strip_tags($token[0]);
				$get_token = "EC-$token";
		}

	}

}

[/php]

Any ideas on this guys? Its the last thing holding up my project :-[

Sponsor our Newsletter | Privacy Policy | Terms of Service