• Stop being a LURKER - join our dealer community and get involved. Sign up and start a conversation.

Reply to thread

Here you go.


[code]

/* This notice must be untouched at all times.



Copyright (c) 2008 AutoJini.com. All Rights Reserved.

Based on Post at (http://forum.dealerrefresh.com/f51/reynolds-closes-modem-access-561.html)

Created 5. 11. 2008 by Umer Farooq (Web: http://www.autojini.com)


LICENSE: LGPL


This library is free software; you can redistribute it and/or

modify it under the terms of the GNU Lesser General Public

License (LGPL) as published by the Free Software Foundation; either

version 2.1 of the License, or (at your option) any later version.


This library is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

Lesser General Public License for more details.


You should have received a copy of the GNU Lesser General Public

License along with this library; if not, write to the Free Software

Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA,

or see http://www.gnu.org/copyleft/lesser.html

*/




define(USER_AGENT, 'com.reyrey.ds.eai.xmppagent.DmsTxBasePost');

$ERAServerIP = '###.###.###.###';



##### MAIN METHOD TO DOWNLOAD THE DATA USING RCI ################


function downloadData($post_data, $outputFile, $ERAServerIP)

{

$header_array[] = "Content-type: text/xml";



     $ch = curl_init();

      curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array);

      curl_setopt($ch, CURLOPT_POST, true);

      curl_setopt($ch, CURLOPT_URL, 'http://' . $ERAServerIP .':8100/salesbin/ServerVehInvView');

      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

      curl_setopt($ch, CURLOPT_USERAGENT, USER_AGENT);

      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);

     



$datum =     curl_exec($ch);

            curl_close($ch);


// Extract CDATA

$cdata_pos_1    =    strpos($datum, 'GenTransStatus Status="Success"/>');

$cdata_pos_2    =    strpos($datum, '</ERAVehInvView>', $cdata_pos_1);

$cdata_subs        =    substr($datum, ($cdata_pos_1 + 33), (($cdata_pos_2 - $cdata_pos_1) - 33));


echo $datum;




if(strpos($datum, '<GenTransStatus Status="Failure"'))

{

    return "\n";

}

else

{

    return $cdata_subs;

}

}


##### HELPER METHOD TO BUILD THE POST FOR RCI ################


function getPostData($storeId, $startPrice, $maxPrice){

    $post_data    =    '<?xml version="1.0" standalone="no" ?>

<!DOCTYPE TransmissionWrapper SYSTEM

"http://b2b.reyrey.com/dtds/ERA/TransmissionWrapper.dtd">

<TransmissionWrapper TransmissionID="'.time().'">

<TransmissionData><![CDATA[

<?xml version="1.0" standalone="no" ?>

<!DOCTYPE ERAVehInvRequest SYSTEM "/vobs/era/sales01/j_src/com/reyrey/sales/dtd/ERAVehInvRequest.dtd">

<ERAVehInvRequest>

    <GenTransData OrigSysID="SALESFORCE" ProcSysID="XXXXXXXXXXXXXXX"

            StoreNo="'. $storeId .'" BranchNo="01" TransCode="VI" TransOpType="Query"

            TZ="PST" ClientId="SALESFORCE">

    <TransTimeStamp Date="'.date("m/d/Y").'" Time="'.date("H:i:s").'"/>

    </GenTransData>

    <QueryFields ERAAppl="sales" NeworUsed="N" StockNo="" VIN="" VehMake=""

                 VehModel="" Carline="" VehYear="" LowPrice="'. $startPrice .'" HighPrice="'. $maxPrice .'" />

    <OtherCriteria Name="NoRecordsToSuccess" Value="YES"/>

</ERAVehInvRequest>

]]></TransmissionData>

</TransmissionWrapper>';

return $post_data;


}

[/code]