-
Notifications
You must be signed in to change notification settings - Fork 93
Using the extended functions for data source development
There are 4 principle functions available to the caller ID sources.
They are:
-
get_url_contents Returns a string containing the contents of url specified by url and other optional parameters.
-
match_pattern Parses Asterisk dial patterns...
-
cisf_url_encode_array Encode an array for transmission in http request...
-
cisf_find_area Search an array of area codes...
(Available in Superfecta v2.2.4 - 2.2.X)
- match_pattern (string pattern, string number) Parses Asterisk dial patterns and produces a resulting number if the match is successful or false if there is no match.
Explain parm1.
h3. Parm2 -- (required/option)
Explain parm2.
h2. Examples:
h3. Example1
h3. Example2
h3. Example3
h1.
h1. cisf_url_encode_array
(Available in Superfecta v2.2.4 - 2.2.X)
h2. Description:
-
cisf_url_encode_array (array array)
Encode an array for transmission in http request
h2. Parameters:
h3. Parm1 -- (required/option)
Explain parm1.
h3. Parm2 -- (required/option)
Explain parm1.
h2. Examples:
h3. Example1
h3. Example2
h3. Example3
h1.
h1. cisf_find_area
(Available in Superfecta v2.2.4 - 2.2.X)
h2. Description:
-
cisf_find_area (array area, string full_number)
Search an array of area codes against phone number to find one that matches. Return an array with the area code, area name, and remaining phone number
h2. Parameters:
h3. Parm1 -- (required/option)
Explain parm1.
h3. Parm2 -- (required/option)
Explain parm1.
h2. Examples:
h3. Example1
h3. Example2
h3. Example3
h1.
(Available in Superfecta v2.2.4 - 2.2.X)
get_url_contents (string url, [array post_data], [string referrer], [string cookie_file], [string useragent]) Returns a string containing the contents of url specified by url and other optional parameters.
A string containing the full url of the page you would like to receive.
An array containing the data you would like to post. If not provided or set to false, no data will be posted.
A string containing the full url of the referring page. If not provided or set to false, no referrer will be used.
A string containing the full path to the file you will use to store cookie data. If not provided or set to false, cookies will not be used.
A string containing the user agent to masquerade as. If not provided or set to false, the default user agent is: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
// Set the url
$url = "http://www.google.com";
// Get the url
$result = get_url_contents($url);
// Create the post array. The key is the form element's name, the value is the form element's value
$post_data = array(
"form_element_name_1" => "form_element_value_1",
"form_element_name_2" => "form_element_value_2",
"form_element_name_3" => "form_element_value_3"
);
// Set the url of the page the form data should be submitted to
$url = "http://www.maypage.com/form_proccessing_page";
// Post the form data and return the results
$result = get_url_contents($url, $post_data);
// Set the referring page. In this case, it is the url of the page containing the form.
$referrer ="http://www.telekom.rs/WhitePages/SearchPage.asp";
// Set the url of the page that will be processing the posted data
$url="http://www.telekom.rs/WhitePages/ResultPage.asp";
// Set the data that will be posted
$post_data = array(
'Telefon'=>$phone_number,
'Ulica'=>'',
'MG'=>$area_code,
'Ime'=>'',
'Broj'=>'',
'Mesto'=>'',
'Prezime'=>'',
'submit.x'=>'58',
'submit.y'=>'10'
);
// Create a temporary path for a cookie file in the /tmp directory
$cookie_file = tempnam("/tmp", "CURLCOOKIE");
// Load the results page once to get some cookies set.
// The first result will fail, but the cookie file will be populated
$result = get_url_contents($url,$post_data,$referrer,$cookie_file);
// Load the results page again, now that our cookie file has valid cookies
$result = get_url_contents($url,$post_data,$referrer,$cookie_file);
// Delete the temporary cookie file, since we no longer need it
@unlink($cookie_file);