Convert asp function to php
Hi i am developing a free shopping basket, I have an asp function taken from google code for there gateway, I have very little knowlage of php and would like some help in the conversion
The Asp Function
This takes the xml that is your shopping basket and does a server to server request, if all is well google will retuen an URL to redirect to
you pass in your XML the url you want to submit to and both your merchant id and key
Function SendRequest(Xml, Url, id, key)
Dim XmlHttp, BasicAuthentication, ResponseXml
Set XmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
XmlHttp.Open "POST", Url, false
Const SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS = 2
Const SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS = 13056
XmlHttp.SetOption SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS, _
(XmlHttp.getOption(SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS) - _
SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS)
BasicAuthentication = Base64Encode(id & ":" & Key)
XmlH开发者_如何学Cttp.SetRequestHeader "Authorization", "Basic " & BasicAuthentication
XmlHttp.SetRequestHeader "Content-Type", "application/xml; charset=UTF-8"
XmlHttp.SetRequestHeader "Accept", "application/xml; charset=UTF-8"
XmlHttp.Send Xml
ResponseXml = XmlHttp.ResponseText
SendRequest = ResponseXml
Set XmlHttp = Nothing
End Function
The php equivalent of XmlHttp
is Curl
You should be able to rebuild the function in php5 using curl, Although there is already a prebuilt php5 library
My php Google Checkout
My PHP Google Checkout is a library written for PHP5 that allows for easy integration with the Google Checkout API and Payment process system. It provides a basic server class for processing notifications, a MySQL implementation that logs and tracks payments in a database, a shopping cart framework for managing items in a cart for for composing your "Google Checkout" button. It is easy to extend, and is perfect for traditional OOP programmers.
精彩评论