cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Sending a XML using Curl

From: haroon ahmad <haroon_at_fastcreators.com>
Date: Thu, 13 Nov 2008 17:53:04 +0500

First try the simplest possible curl script to fetch any page and see if it
works.

If your service provider system works really, then the following code must
work.

$request= utf8_encode('<?xml version="1.0" encoding="ISO-8859-9" ?>
<ePaymentMsg VersionInfo="2.0" TT="Request" RM="Direct" CT="Money">
    <Operation ActionType="Sale">
        <OpData>
            <MerchantInfo MerchantId="12345678" MerchantPassword="1111111"/>
            <ActionInfo>
                <TrnxCommon TrnxID="TRX_1a2b3c4d5e6f7g" Protocol="156">
                    <AmountInfo Amount="1.00" Currency="949" />
                </TrnxCommon>
                <PaymentTypeInfo>
                    <InstallmentInfo NumberOfInstallments="0" />
                </PaymentTypeInfo>
            </ActionInfo>
            <PANInfo PAN="1111222233334444" ExpiryDate="200911"
CVV2="123" BrandID="VISA" />
            <OrderInfo>
                <OrderLine>1</OrderLine>
                <OrderText>Urun_Ismi</OrderText>
            </OrderInfo>
            <OrgTrnxInfo />
        </OpData>
    </Operation>
</ePaymentMsg>');

   $ch=curl_init();
   // Set parameters
   curl_setopt($ch, CURLOPT_URL,
"https://web.bankasya.com.tr/spos/iposnet/sposnet.aspx";);
   // Return a variable instead of posting it directly
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   // Active the POST method
   curl_setopt($ch, CURLOPT_POST, 1) ;
   // Request
   curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
   // execute the connexion
   $result = curl_exec($ch);
   // Close it
   curl_close($ch);
   echo "<textare rows=10 cols=80>$result</textarea>";

Haroon Ahmad
PHP Web Developer
www.haroonahmad.co.uk

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-11-13