mandi_08 Posted September 4, 2008 Share Posted September 4, 2008 I have a php code that needs translating to VBA (For MSAccess) and I don't know where to begin. I've tried looking for an online converter with no success. Thanks in advance. Mandi <?php // First we need to feed the SKU, for now we use 1088963 as an example $td_sku="1088963"; //Following the XML data $xmldata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r <OnlineCheck>\r <Header>\r <BuyerAccountId>------</BuyerAccountId>\r <AuthCode>---------</AuthCode>\r <Type>Full</Type>\r </Header>\r <Item line=\"1\">\r <ManufacturerItemIdentifier/>\r <ResellerItemIdentifier/>\r <DistributorItemIdentifier>$td_sku</DistributorItemIdentifier>\r <Quantity>1</Quantity>\r </Item>\r </OnlineCheck>"; $fp = fsockopen("my-website-here.com", 8080, $errno, $errstr, 15); //Generate the postdata on a valid way, $out4 needs to be calculated, so will be later. $out1 = "POST /Onlchk HTTP/1.0\r "; $out2 = "Content-Type: multipart/form-data; boundary=---------------------------2\r "; $out3 = "Host: my-website-here.com:8080\r "; $out5 = "Connection: close\r \r "; $out6 = "-----------------------------2\r "; $out7 = "Content-Disposition: form-data; name=\"onlinecheck\"\r \r "; $out8 = "\r -----------------------------2--"; //Calculation of the Content-Length: $tlen=strlen($out6)+strlen($out7)+strlen($xmldata)+strlen($out8); $out4 = "Content-Length: $tlen\r "; //Generate full output $out = $out1.$out2.$out3.$out4.$out5.$out6.$out7.$xmldata.$out8; fwrite($fp, $out); $retval = ""; while(!feof($fp)){$retval = "$retval".fgets($fp,128);} fclose($fp); list($headers,$body) = explode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>",$retval); $doc = new DOMDocument(); $doc ->LoadXML($body); $item_ids = $doc->getElementsByTagname( "OnlineCheck" ); foreach( $item_ids as $item ) { $error_s = $item->getElementsByTagName( "Errorstatus" ); $tderror = $error_s->item(0)->nodeValue; $stock_s = $item->getElementsByTagName( "AvailabilityTotal" ); $tdstock = $stock_s->item(0)->nodeValue; // Reformatting the price to ISO compatible format $price_s = $item->getElementsByTagName( "UnitPriceAmount" ); $tdprice = str_replace('.','',$price_s->item(0)->nodeValue); $tdprice=str_replace(',','.',$tdprice); } //Rest of handling off the data under here ?> Link to comment https://forums.phpfreaks.com/topic/122682-can-you-help-with-php-vba-conversion/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.