Data feed file integration price comparison shopping script

Documentation Wiki - - Online merchant datafeed integration for affiliates : DFFClientLibraryPHP

HomePage | Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
Home Affiliate FAQ Merchant FAQ Examples Merchants Networks & Programs Forum Blog Wiki Knowledge Base Login

DFF PHP Client Library / API

The purpose of this PHP class is to help affiliates / webmaster / programmers who would like to integrate DFF's shopping tools and price comparison shopping data easier.
DFF Client Library contains methods to request data and parse respond from DFF server into usable array.
Using DFF Client Library will allow programmers to concentrate on their web site functionality instead of developing communication scripts to grab data from DFF server.

Dependencies of DFF Client Library
DFF Client Library relies on a few DFF function files such as DFF_dffml.func.php and DFF_tag.func.php at least for version 1.0.0. The dependencies may change in future version. It is best to use DFF Client Library with the whole DFF Framework API as all the dependencies are included in the framework package. You can see all list of dependencies from the commented header section of the library.

How to use DFF Client Library
  1. include DFF_config.php
    Before using any DFF library class or function, you should always make sure DFF_config.php file is loaded. To make sure it is loaded just once use:
            require_once 'DFF/DFF_config.php';

  2. include the DFF Client library class file:
            require_once $DFF_config['dir_include'].'DFF_affiliate_client_API.php';

  3. It is basically a class, so first your have to create an object for the class to exists:
            $dff_request = new DFF_Client_API;

  4. Set default values from DFF_config.php into class variables:

    This will load your DFF affiliate ID (affid),DFF Token and default SubID into the new object.

  5. Set filters and parameters:
    Depending on which DFF Library Script Type you are accessing, the code(s) to set filters and parameters will be different for each DFF Library Script Type.
    For example for Deal Search Engine (DSE) to set filter for keyword 'phone', limit 20 results per page and start from page 2 is:
            $deal_params['keyword'] = 'phone';
            $deal_params['limit'] = 20;
            $deal_params['page'] = 2;

    $deal_params is just an array to contain all the filters and parameters to be passed into the post_request method later. You can use any array variable name instead of $deal_params.

  6. Make request to DFF server via HTTP POST:
            $result = $dff_request->post_request(DFF_DSE,$deal_params);

    In this example we use DFF_DSE at the DFF Library Script Type and we also passed all our filters and parameters we have built into $deal_params earlier.
    You may want to check on the $result variable to make sure POST request was successful before trying to decode data into array.

  7. Convert POST result data to native array:

    Once this object method has been executed, it will decode the JSON response data and load the $dff_request->result_array array with all the returned data from DFF server.

  1. Merging array ($dff_request->result_array) with DFFML string:
    If you have already prepared a DFFML string to be merge with the returned data, you use the following method to merge DFFML + returned data right away:
    If you have your DFFML inside a string variable:
            $dffml_output = DFF_merge_array_DFFML($DFFML_string, $dff_request->result_array);

    If you have your DFFML inside a file in the **dffml** directory in your document root (not inside the DFF framework directory):
            $dffml_output = $dff_request->get_DFFML_output($config['url_dffml'].'DFFML_DSE_home_page_middle.php');

    Please make sure you have converted the returned data into array using convert_json_to_array() first before merging with data array with DFFML.

  2. Display the HTML codes newly generated via DFFML merge:
    Using PHP:
            echo $dffml_output;

     Using HTML + PHP:
    		.... <?=$dffml_output?> ....

Here it is all together
  1.     require_once 'DFF/DFF_config.php';
  2.     require_once $DFF_config['dir_include'].'DFF_affiliate_client_API-1.0.0.php';
  5.     $dff_request = new DFF_Client_API;
  6.     $dff_request->set_using_DFF_config();
  7.     $deal_params['keyword'] = 'phone';
  8.     $deal_params['limit'] = 20;
  9.     $deal_params['page'] = 2;
  10.     //$deal_params['debug'] = 1;        //optional debug on/off
  13.     $result = $dff_request->post_request(DFF_DSE,$deal_params);
  15.     // LOAD DFFML_string variable, see note at the bottom of this example.
  18.     if($result) {
  19.         $dff_request->convert_json_to_array();
  20.         $dffml_output = DFF_merge_array_DFFML($DFFML_string, $dff_request->result_array);
  21.     } else {
  22.         die('DFF Post Request Failed');
  23.     }
  25.     // DISPLAY THE HTML
  26.     echo $dffml_output;

The example above assume you have the variable $DFFML_string loaded with DFFML content. The reason we have left it out of the example is because the DFFML content is large and will make the example above hard to read. But here is the PHP code needed to be inserted after the comment LOAD DFFML_string at the above example.
<div id="dff_number_found"><|DFF|stats=>count|> deals found&nbsp;&nbsp;<span style="font-size:8pt">showing: <|DFF|stats=>rec_start|> to <|DFF|stats=>rec_end|></div>
<div class="post" style="padding-left:0px;width:685px;text-align:left">
    <h2 class="title" style="text-align:left">Deals <|DFF|name|></h2>
        <div id="dff_deal_title"><a href="<|DFF|target_url|>"><|DFF|headline|></a></div>
        <div class="dff_deal_entry">
            <table cellpadding="0" cellspacing="0">
                    <td colspan="2">
                        <div id="dff_deal_subtitle_bar">
                            <table cellpadding="0" cellspacing="0" width="100%">
                                    <td width="70%"><span class="dff_deal_category"><|DFF|category|></span></td>
                                    <td width="30%" align="right">
                                        <span class="dff_deal_links">
                                            <a href="<|DFF|PHP{DFF_config=>url_base}|>search.php%3Fdealnum=<|DFF|dealnum|>&title=<|DFF|urlencode()^headline|>"><img src="image/digg.png" border="0" target="_blank"></a>
                                            <a href="<|DFF|PHP{DFF_config=>url_base}|>search.php%3Fdealnum=<|DFF|dealnum|>;title=<|DFF|urlencode()^headline|>"><img src="image/delicious.png" border="0" target="_blank"></a>
                                            <a href="<|DFF|urlencode()^headline|>&u=<|DFF|PHP{DFF_config=>url_base}|>search.php%3Fdealnum=<|DFF|dealnum|>"><img src="image/yahoomyweb.gif" border="0" target="_blank"></a>
                                            <a href="<|DFF|PHP{DFF_config=>url_base}|>search.php%3Fdealnum=<|DFF|dealnum|>&t=<|DFF|urlencode()^headline|>"><img src="image/furl.png" border="0" target="_blank"></a>&nbsp;
                    <td valign="top" width="100%">
                        <div class="dff_deal_footer">
                            <span class="dff_deal_store"><a href="search.php?mernum=<|DFF|mernum|>&mername=<|DFF|urlencode()^mername|>"><|DFF|mername|></a></span>
                            <span class="dff_deal_posted_date">Posted: <|DFF|created_date|></span>
                            <span class="dff_deal_expiration_date">Expire: <|DFF|expiration_date|></span>
                    <td valign="top"><a href="<|DFF|target_url|>"><img class="dff_deal_image" align="right" valign="top" border="0" target="_blank" alt="<|DFF|headline|>" title="<|DFF|headline|>" src="<|DFF|dealnum|>&m=<|DFF|mernum|>&u=<|DFF|urlencode()^picture_url|>"></a></td>

JSON Support for PHP 4.x
JSON decode and encode functionality is not available in PHP 4.x but required by DFF Framework API.
DFF Client Library for PHP should automatically detect, include and use additional PHP include file called JSON.php which will add the JSON encode and decode functionality.

JSON was added natively to PHP 5.x. For those users still using PHP 4.x please read the link below regarding adding support for PHP 4.x.
How to add JSON encode & decode functionality to PHP 4.x

Again this example only demonstrate using DFF Client Library to access and display DSE Deal Search Engine script type. Please see all other DFF Library Script Types.

There are no comments on this page. [Add comment]

Integrate price comparison shopping data feed file from thousands of online merchant product data feeds | Valid CSS

Page was generated in 0.2344 seconds