PHP eFax
|
Object to send one request. More...
Public Member Functions | |
http_request ($url) | |
Initialize the HTTP request object. More... | |
setOptions ($options) | |
Set options. More... | |
addHeaders ($headers) | |
Add one or more headers to the object. More... | |
addPostFields ($post_fields) | |
Add a set of fields to the request. More... | |
send () | |
Send the request to the server. More... | |
This class can be used to send ONE request to an e-Fax server. The request may fail in which case an exception is raised. In most cases it is possible to retry to get it to work. The servers may not always respond because too many requests are received all at once and thus your server does not connect. This is normal behavior.
Note that one http_request object can be used to send at most ONE request. To send another request, create a new object or you are likely to get surprises.
The main function is the send() function, but you should always call the addPostFields() before sending anything. The options currently support the 'redirect' option. If not defined the default is 3.
http_request::addHeaders | ( | $headers | ) |
This function is an empty stub. Headers are always forced in the send() function.
[in] | $headers | Ignored. |
http_request::addPostFields | ( | $post_fields | ) |
This function saves fields in the request. Note that it is not currently possible to remove existing fields. This function is cumulative so multiple calls to it adds the new fields (although it will overwrite old fields if the new array includes the same name.)
Be careful as the name of fields is viewed as case sensitive at this level. So 'Id' and 'id' are two distinct fields.
[in] | $post_fields | The fields to post in the send() request. |
http_request::http_request | ( | $url | ) |
This object is in replacement of the PEAR HttpRequest object that require a compiled library which has been discontinued.
To further initialize the class, call the setOptions() and addPostFields(). The addHeaders() function is a stub so it is not necessary to call it. Since SSL is enforced, only the number of redirects is taken in account from the options.
[in] | $url | The URL used to send the e-Fax request. |
http_request::send | ( | ) |
This function sends the request to the output server. The server was defined when creating the object (the constructor takes a $url).
The function returns an http_response object if the request goes through without errors (reply with "HTTP/1.1 200 OK".) The function supports redirects so on 301 the server information is updated with the Location header and a new request sent. This is ALWAYS done with SSL.
http_request_exception | is raised whenever an invalid parameter is detected or we received an invalid reply. |
HttpInvalidParamException | is raised whenever the socket times out. This exception is used to be compatible with the PEAR HttpRequest class. |
http_request::setOptions | ( | $options | ) |
This function sets the options of the class. Note that each time you call this function all the options are reset by the new ones that you specify when calling.
The options are defined in an array with the index defined as the name of the option and the content as the value of the option. For example:
[in] | $options | The options to save in this object. |