CORE POS - Fannie
The CORE POS back end
Public Member Functions | List of all members
SelectInvoiceTask Class Reference
Inheritance diagram for SelectInvoiceTask:
FannieTask

Public Member Functions

 run ()
 
- Public Member Functions inherited from FannieTask
 setThreshold ($t)
 
 setConfig (FannieConfig $fc)
 
 setLogger (FannieLogger $fl)
 
 setOptions ($o)
 
 setArguments ($a)
 
 run ()
 
 cronMsg ($str, $severity=6)
 
 lazyGetOpt ($argv)
 

Additional Inherited Members

- Public Attributes inherited from FannieTask
 $name = 'Fannie Task'
 
 $description = 'Information about the task'
 
 $default_schedule
 
 $schedulable = true
 
const TASK_NO_ERROR = 0
 
const TASK_TRIVIAL_ERROR = 1
 
const TASK_SMALL_ERROR = 2
 
const TASK_MEDIUM_ERROR = 3
 
const TASK_LARGE_ERROR = 4
 
const TASK_WORST_ERROR = 5
 
- Protected Attributes inherited from FannieTask
 $error_threshold = 99
 
 $config = null
 
 $logger = null
 
 $options = array()
 
 $arguments = array()
 

Member Function Documentation

SelectInvoiceTask::run ( )

Step 1: Download the login page

Get hidden fields from login page

add username and password

POST login info back to login page

Find iframes in the resulting page Need to download the iframe which contains a big XML token, the POST that token to the home URL

Note: The Referer header field is required when downloading the iframe. If that header isn't set, you won't get a valid result.

Posting the token to the home URL return an HTTP 403 and a page saying you need to login first. This is not accurate. Subsequent requests will be logged in.

Requesting session value isn't necessary Using a browser does this but I never get a valid result when using the script and it doesn't seem to matter. $ch = curl_init($SESSION_URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, ''); $session_page = curl_exec($ch); curl_close($ch);

Get invoice download page

Extract available dates They're now embedded in javascript as JSON list of objects instead of being in a <select> field

Extract inputs by id They contain some useful information for the actual downloads.

POST a JSON value to request a particular report The response will be a simple JSON object containing the actual file URL. { "d" : "http://customer.unfi.com/path/to/file.zip" }

Cleanup: delete cookie file


The documentation for this class was generated from the following file: