<?php
require_once('/home/users/web/b2584/ipw.redpassion/public_html/88sichuan/ringcentral/ringcentral.phar');
$fax_info ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<header>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</header>
<BODY STYLE="font-family: Lucida Sans, sans-serif"> <u><font size=3> RED PASSION: (8 8 8) 387-3312<br> <a href="http://redpassion.ipower.com/88sichuan">88 sichuan</a> # <a href="http://redpassion.ipower.com/88sichuan/show_order.php?red=order&oID=5037">5037</a></font></u><br><b><font size=4>PICKUP(来拿): <b>Cash</b></font><br> <font size=4>ASAP(尽快) </b><br> Order@:<b>08/29 Wed 9:20PM</font></b><table border="0" width="100%" cellspacing="0" cellpadding="2"><tr><td valign="top" width="100%">(413)-345-2345 <a href="mailto:jhuang@wi.rr.com">Joe Huang</a> </td></tr></table><hr>
<table border="0" width="100%" cellspacing="0" cellpadding="4"> <tr class="dataTableRow">
<td class="dataTableContent" valign="top" align="left" width="10%">4 </td>
<td valign="top" width="80%"><b><font FACE="Lucida Sans, sans-serif" size=3>43 Fried Shrimp & Walnuts w. Mayonnaise Sauce<br><small> <i> ** Plain Fried Rice +$1 (+$4.00)</i></small> </font> </b></td> <td align="right" valign="top"><b>$79.96</b></td> </tr></table><table border="0" width="100%" cellspacing="0" cellpadding="2"><tr>
<td align="right" > </td>
<td></td><td align="right" nowrap="nowrap" colspan="2">---------</td> </tr>
<tr><td></td><td align="right" nowrap="nowrap" colspam="2" ><font FACE="Lucida Sans, sans-serif" size=3> Sub-Total:</font></td>
<td align="right" nowrap="nowrap" ><font FACE="Lucida Sans, sans-serif" szie=3> <b>$79.96</b> </font> </td> </tr>
<tr><td></td><td align="right" nowrap="nowrap" colspam="2" ><font FACE="Lucida Sans, sans-serif" size=3> <span class="red">Buy 2 Get 1 Free:</span></font></td>
<td align="right" nowrap="nowrap" ><font FACE="Lucida Sans, sans-serif" szie=3> <b>-$19.99</b> </font> </td> </tr>
<tr><td></td><td align="right" nowrap="nowrap" colspam="2" ><font FACE="Lucida Sans, sans-serif" size=3> Store Pickup (Walk In):</font></td>
<td align="right" nowrap="nowrap" ><font FACE="Lucida Sans, sans-serif" szie=3> <b>$0.00</b> </font> </td> </tr>
<tr><td></td><td align="right" nowrap="nowrap" colspam="2" ><font FACE="Lucida Sans, sans-serif" size=3> TAX:</font></td>
<td align="right" nowrap="nowrap" ><font FACE="Lucida Sans, sans-serif" szie=3> <b>$5.80</b> </font> </td> </tr>
<tr><td></td><td align="right" nowrap="nowrap" colspam="2" ><font FACE="Lucida Sans, sans-serif" size=3> <div class="ot_loyality_title">Customer Loyalty Discount:</div><span class="ot_loyality_text">You have ordered $1,098.04 in the last 31 days, so you have a discount of 10% .</span></font></td>
<td align="right" nowrap="nowrap" ><font FACE="Lucida Sans, sans-serif" szie=3> <b>-<span class="ot_loyality_amount">$6.58</span></b> </font> </td> </tr>
<tr><td align="right" width="30%" ><font FACE="Lucida Sans, sans-serif" size=4></td><td align="right" nowrap="nowrap" width="20%"><font FACE="Lucida Sans, sans-serif" size=4> Total:</font></td>
<td align="right" nowrap="nowrap" ><font FACE="Lucida Sans, sans-serif" szie=3> <b>$59.19</b> </font> </td> </tr>
<tr></table><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr><td align="left" width="60%">Thanks</table><hr><font size=3>
';
$order_id = '5038.html';
$ext = rand('300','309');
try {
//RingCentral\SDK\SDK::SERVER_SANDBOX RingCentral\SDK\SDK::SERVER_PRODUCTION 8bTYD-nRRN65AYU0gH3cSg
//$sdk = new RingCentral\SDK\SDK('5Z9d86cFSniG5TB4NPvvuQ', 'WVd87RDkTfyMdeQF9X5OfwQ88AhG1RQaK-r65Dd92L5w', 'https://platform.devtest.ringcentral.com', 'Demo', '1.0.0');
$sdk = new RingCentral\SDK\SDK('Cv_ZTTp9Tk-M4cMXBFPBeQ', 'bQ2C_2PrSJOY_jPPki68UQMRGB5yoASbyHUXCQkYQxDQ', 'https://platform.ringcentral.com', 'PROD', '1.0.0');
$platform = $sdk->platform();
//$platform->login('12679304359', '101', 'Alena1129');
$platform->login('18883873312', $ext, 'Alena1129');
//$sdk->platform()->login('18883873312', '101', 'Alena1129');
//$sdk->platform()->login('18883873312', '103', 'menu88$$');
$order_url = HTTP_SERVER . DIR_WS_CATALOG . 'show_order.php?red=order&oID=' . (int)$zf_insert_id;
$request = $sdk->createMultipartBuilder()
->setBody(array(
'to' => array(
array('phoneNumber' => '2622268388'),
),
'faxResolution' => 'High',
'coverIndex' => '0',
))
->add($fax_info, $order_id)
//->add(fopen('https://redpassion.ipower.com/88sichuan/show_order.php?red=order&oID=5032', 'r'),'5032.html')
->request('/account/~/extension/~/fax');
//print $request->getBody() . PHP_EOL;
$response = $platform->sendRequest($request);
print 'Sent Fax ' . $response->json()->uri . PHP_EOL;
} catch (\RingCentral\SDK\Http\ApiException $e) {
$from = 'jhuang@redpassionhost.com';
$subject = 'Red Passion:'. (int)$zf_insert_id;
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$message = ' '. HTTP_SERVER . DIR_WS_CATALOG . 'show_order.php?red=order&oID=' . (int)$zf_insert_id .'-metrofax ';
$message .= ' API Error: ' . $e->getMessage(). PHP_EOL;
mail('spancfreedom@gmail.com', $subject, $message, $headers);
}
?>