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...
¶
match_pattern¶
(Available in Superfecta v2.2.4 - 2.2.X)
Description:¶
- 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.
Parameters:¶
Parm1 -- (required)¶
Explain parm1.
Parm2 -- (required/option)¶
Explain parm2.
Examples:¶
Example1¶
Example2¶
Example3¶
¶
cisf_url_encode_array¶
(Available in Superfecta v2.2.4 - 2.2.X)
Description:¶
- cisf_url_encode_array (array array)
Encode an array for transmission in http request
Parameters:¶
Parm1 -- (required/option)¶
Explain parm1.
Parm2 -- (required/option)¶
Explain parm1.
Examples:¶
Example1¶
Example2¶
Example3¶
¶
cisf_find_area¶
(Available in Superfecta v2.2.4 - 2.2.X)
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
Parameters:¶
Parm1 -- (required/option)¶
Explain parm1.
Parm2 -- (required/option)¶
Explain parm1.
Examples:¶
Example1¶
Example2¶
Example3¶
¶
get_url_contents¶
(Available in Superfecta v2.2.4 - 2.2.X)
Description:¶
- 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.
Parameters:¶
url -- (required)¶
A string containing the full url of the page you would like to receive.
post_data -- (optional)¶
An array containing the data you would like to post. If not provided or set to false, no data will be posted.
referrer -- (optional)¶
A string containing the full url of the referring page. If not provided or set to false, no referrer will be used.
cookie_file -- (optional)¶
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.
useragent -- (optional)¶
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
Examples:¶
Simple url¶
// Set the url $url = "http://www.google.com"; // Get the url $result = get_url_contents($url);
Post data¶
// 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);
Using cookies and referrer to post data to a page requiring cookies and a referrer.¶
// 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);