ag_apikey = get_option('agent_apikey'); //get agent username from wordpress admin options $this->ag_username = get_option('agent_username'); //get max_results from wordpress admin options $this->ag_max_results = get_option('agent_max_results'); } //sidebar widget sale transactions api call function sidebar_sale_transactions($start_index){ $request_url = "http://www.agentrank.com/api/rest/sales/agent/"; $request_url .= "$this->ag_username?api_key=$this->ag_apikey"; $request_url .= "&start_index=$start_index&max_results=$this->ag_max_results"; $request_url = urlencode($request_url); //Adding the "@" symbol in front of any function call will suppress any //PHP-generated error messages from that function call. $response_xml = @simplexml_load_file($request_url); //check xml structure, it should return a status code //if not, do not return xml to sidebar widget. //Checking of structure will ensure that 404 or 503 from Apache Server, which is html page //will not pass through to sidebar widget and cause xml parsing error if (!empty($response_xml->status['code'])) { return $response_xml; } } function view_sale_transactions($sale_id){ $request_url = "http://www.agentrank.com/api/rest/sale/view/"; $request_url .= "$sale_id?api_key=$this->ag_apikey"; $request_url = urlencode($request_url); $response_xml = @simplexml_load_file($request_url); if (!empty($response_xml->status['code'])) { return $response_xml; } } function view_all_sales($start_index,$display){ $request_url = "http://www.agentrank.com/api/rest/sales/agent/"; $request_url .= "$this->ag_username?api_key=$this->ag_apikey"; $request_url .= "&start_index=$start_index&max_results=$display"; $request_url = urlencode($request_url); $response_xml = @simplexml_load_file($request_url); if (!empty($response_xml->status['code'])) { return $response_xml; } } } if(!isset($agapi)){ $agapi = new agentrankapi; } ?>