Question 


$t->Fetch( ) - With 'GET' Example


Answer 


$t->fetch( )


With 'Get' Example

$t->fetch($url)

Description #

A “get” is straightforward to construct in a fetch command. Parameters ( to ) are merely substituted into the constructed url string in the fetch. Identifying which parameters are used within the input string is usually relatively easy to ascertain by experimenting with various searches and examining the URL string sent.

Parameters # 

$url - A String containing the requested URL e.g. "[http://www.requestedurl.com"]

Return values# 

Page source or structured data XML

Examples #

$t->fetch("[http://blinkmobile.squarespace.com/display/Search?searchQuery="] . $args[0] . "&moduleId=6598880");
$t->between("

", "

");  $t->rows(   "|

~*<a href=\"{URL}\">~*hit-word-title\">{TITLE}~*search-result-date\">{DATE}~*search-result-body\">{COPY}

|U",   ""  );  if($t->isblank()){   return "Your search returned no results"; }  return $t->result;


Question


$t->Fetch( ) - With Search Parameters Example


Answer 


$t->fetch( )

With Search Parameters Example

$url="[http://www.abcdrivingschool.com.au/"] . $args[0];
$t->fetch($url);

Description #

A very simple fetch may just request a URL with an additional parameter. This argument is normally sent from a list or search Interaction. One other way of do this is to pass the argument from the "Input Config" field in the interaction builder. (As shown in example 2)

Parameters #

$url - A String containing the requested URL e.g. "[http://www.requestedurl.com"] plus an agreement passed in $args[0]

Return values#

Returns requested source into $t->result

Examples #

Example 1

$url="[http://www.abcdrivingschool.com.au/"] . $args[0];
$t->fetch($url);

Example 2 

Code in Input config section

 Bilinga Broadbeach Burleigh Heads Coolangatta Currumbin Kirra Main Beach Mermaid Beach Palm Beach Rainbow Bay Runaway Bay South Stradbroke Island Surfers Paradise Tallebudgera Tugun
<arg>
 <prefix>Beach:{NL}</prefix>
 <select>
<option value="bilinga">Bilinga</option>
<option value="broadbeach">Broadbeach</option>
<option value="burleigh-heads">Burleigh Heads</option>
<option value="coolangatta">Coolangatta</option>
<option value="currumbin">Currumbin</option>
<option value="kirra">Kirra</option>
<option value="main-beach">Main Beach</option>
<option value="mermaid-beach">Mermaid Beach</option>
<option value="palm-beach">Palm Beach</option>
<option value="rainbow-bay">Rainbow Bay</option>
<option value="runaway-bay">Runaway Bay</option>
<option value="south-stradbroke-island">South Stradbroke Island</option>
<option value="surfers-paradise">Surfers Paradise</option>
<option value="tallebudgera">Tallebudgera</option>
<option value="tugun">Tugun</option>
</select>
</arg> 

Code

$t->fetch("[http://www.verygoldcoast.com.au/]$args[0]/");

Question 

 $t->Fetch( ) - A Simple Fetch Example

Answer 

$t->fetch( )

A Simple Fetch Example

$t->fetch($url);

Description #

A very simple fetch may just request a URL without any additional parameters.

Parameters #

$url - A String containing the requested URL e.g. "[http://www.requestedurl.com"]

Return values# 

Returns requested source into $t->result

Examples #

$t->fetch("[http://blinkmobile.com.au/");] \\
return $t->result;


Question 

 

$t->submitForm( )


Answer 


$t->submitForm( )

$t->submitForm($mystring, $myarray)

Description #

Often known as a "PassThru"... On occasions when you are retrieving a page source into an Interaction you may require authorisation from a login form. SubmitForm function can be used to 1. Fetch the form at the requested url. 2. Submit the required parameters 3. Return the results of the fetch for additional formatting.

Parameters #

*$mystring - A String. The reference to the form name. 0 can be used instead to select the first form found, 1 then next and so on.
*$myarray - As Array of values to be passed to the form.

Return values#

Returns requested source into $t->result

Examples #

$t->fetch("[http://support.blinkmobile.com.au/");]

 $t->submitForm( 0,
    array(
    'username'=>'YourUserName',
    'passwd'=>'YourPassword'
    )
);
return $t->result;

// Page source returned here for additional processing


Question 


$t->Fetch( ) - With 'POST' Example


Answer 


$t->fetch( )

With 'Post' Example

$t->fetch($url, $myarray,'','')

Description #

This function will immediately post data to a form once fetched. A “post” is slightly more complex to construct. Firstly the correct input array must be found within the web page. Unless you have access to documentation or are happy to review the page source yourself you are better off using the INTERACTION code builder to interpret the page and list the forms and variables. Once identified the fetch may be constructed by filling the form variables from the input arguments to .

Parameters #

*$url - A String containing the requested URL e.g. "[http://www.requestedurl.com"]
*$myarray - As Array of values to be passed to the form.

Return values# 

Returns requested source into $t->result

Examples #

$_POST=array(
"method"=>'init',
"callCount"=>1,
"c0-scriptName"=>'null',
"c0-methodName"=>'getFilteredImpounds',
"c0-id"=>"1511_1305600140169");

$t->fetch("[http://www.blblinkmobile.com.au",]$_POST);
return $t->result;


Question 

 

What is a Fetch( ) ?


Answer 


$t->fetch( )

$t->fetch($url, $post = '', $headers = '', $referer = '', $header_in_output = false,

$timeout_seconds = 30, $curlOpts = array())

Description #

Given a URL and post data, the fetch function makes a HTTP request and sets $t->result to be the resulting source code.

By convention we work with a string, $t, applying mADL functions to it. In the fetch function we load the string $t with the page source or structured data (XML or such like) that is to be interpreted. The fetch may be a request for a web page from which the required information will be “parsed” into variables for display or further use, or may be a call to a web API which returns structured data (eg. XML) without any formatting information. Regardless of the format of the return data, the correct fetch must be constructed.

Parameters #

$url - A String containing the requested URL.

$post -An Array or String containing post data or array.

$headers - An Array or String containing page header type.

$referer - An Array or String containing url or page to re-direct to.

$header_in_output=false - A boolean value that defines if the header is included in the output.

$timeout_second=30 - a numeric value for CURLOPT_CONNECTTIMEOUT.

$curlOpts = array() - key-value pair for curl options

Return values#

Page source or structured data / XML

Notes #

The standard user agent set in $t->Fetch( ) is "Mozilla/5.0"

You can set this yourself in the 7th parameter $curlOpts in $t->Fetch( ) to whatever you want.

Similar to using "curl_setopt($ch, CURLOPT_USERAGENT, "booyah!");".