Small API with some simple modifications

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

Post Reply
PaulHend
Forum Newbie
Posts: 1
Joined: Fri May 10, 2013 10:08 am

Small API with some simple modifications

Post by PaulHend »

I have a small API that pulls information such as the product ID from 3DCart Shopping Cart, then passes that information to Yummy to generate a serial number for the downloadable games that a customer purchases.



Currently, the API generates an e-mail that is send to the customer with their product download link and serial number. What it is set up for now is the game will be the product id, for example Game A will have an ID of 1234, so the API will send that e-mail the customer a link to an EXE file.



What we want is to append the 1234 to game a and also include the entire game name to the download link, our client thinks that the customers wouldn't understand downloading a 1234.exe.



What I think I should be looking at is here:

Code: Select all

foreach ($postXmlToObject->Order->ShippingInformation->OrderItems->Item as $item) {
            // grab URL and pass it to the browser
            curl_setopt($ch, CURLOPT_URL, "https://shield.yummy.net/checkpoint/checkpointservice.asmx/nsn/Xlith7696*G36Hye09?GSNLIC={$item->ProductID}&GSNAID=3&GSNPno=0&GSNPAC=3&CPONO={$orderId}");
            $serialNumber = curl_exec($ch);
            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            // Check if any error occurred
            if ($httpCode == 200 && !empty($serialNumber) && (int)$item->ProductID < 10000) {
                $updateOrderSerialNumbers .= '<br/><br/>Item ID: '.(string)$item->ProductID.'<br/>Serial number: '.$serialNumber;
                $serialCodeText .= '<font face="Arial" size="2">
                    <b>
                        '.(string)$item->ProductName.'
                    </b>
                </font>
                <br>
                <font face="Arial" size="2">
                    Download:
                    <a href="http://justadventure.com/download/'.(string)$item->ProductID.'.exe">
                        http://justadventure.com/download/'.(string)$item->ProductID.'.exe
                    </a>
                    <br>
                    Serial number: '.$serialNumber.'
                </font>
                <br><br>';
                $sendMail = true;
            }
        }
Any input is greatly appreciated, thank you in advance!
Post Reply