joeydsmith
2/2/2015 - 3:41 PM

gistfile1.txt

public function fetchUrl_POST($url, $fields){
			//open connection
			$ch = curl_init();
			foreach($fields as $key=>$value) {
				$fields_string .= $key.'='.$value.'&';
			}
			rtrim($fields_string, '&');
			//set the url, number of POST vars, POST data
			curl_setopt($ch, CURLOPT_URL, $url);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_VERBOSE, 0);
			curl_setopt($ch, CURLOPT_POST, count($fields));
			curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
			//execute post
			$feedData = curl_exec($ch);
			curl_close($ch);
			return $feedData;
		}