License = '########'; $this->ip = gethostbyname($_SERVER['SERVER_NAME']); } public function getGawsToken(){ $xml = file_get_contents('https://token.melissadata.net/v3/web/Service.svc/RequestToken?L='.$this->License.'&P=pkgIntAddressCheck&IP='.$this->ip); return $this->_parseXML($xml); flush(); } public function getGeeToken(){ $xml = file_get_contents('https://token.melissadata.net/v3/web/Service.svc/RequestToken?L='.$this->License.'&P=pkgExpressEntry&IP='.$this->ip); return $this->_parseXML($xml); flush(); } private function _parseXML($xml){ $xml_r = new SimpleXMLElement($xml); //grab out the token $token = (string)$xml_r->Token; //send the token to the client in a json packet $data[] = array('token' => $token); //this encodes the data and sends it back to the client return json_encode($data); } } ?>