...

View Full Version : Making an HTTP Request



landguy
11-20-2009, 12:38 AM
I am very new to this and need some help with code for this. Please take it easy on me. By reading the webmasters guide for contentport. I guess it says im am trying to send a http request for xml data to be parsed and returned as html to be included in the main content div of my webpage. I believe the following examples in the webmasters guide are written for windows servers and i'm on linux. Do i need a perl script?
Platform Type Debian
MySQL Version 5.0.77
Perl 5.8.8 and a bunch of installed modules
PHP 5.2.2

If someone could please tutor me through this code and where it goes that would be great.

Thanks, Paul

This is from the webmasters guide for Contentport


Back-End Integration

Contentport provides a growing list of mechanisms for obtaining information and customer data directly in
XML format. Depending on the type, this data may be either pulled periodically by your system, or
pushed to your system by Contentport.


Offer Group XML

The Offer Group XML API allows Contentport web developers a method to directly retrieve the
contents of Offer Groups in standard XML format via an HTTP request to the Contentport system.
This enables the display of Offer Group data anywhere on your website, and allows you to control
the scope and formatting of the data.

Real-time XML Out Process

• A customer visits the website.
• The website sends an HTTP request to the Contentport system.
• The Contentport system retrieves the requested Offer Group data from the database and
returns them in XML format as the HTTP response.
• The website styles the XML data as necessary for display.

Accessing the Offer Group XML API

All requests to the Offer Group XML API are based on the following basic link:

http://www.contentport.com/xmlout/GetSSXML.asp?site=SiteCode&account=AccountCode

Making an HTTP Request

Depending on the server technology you use to host your website, the options available to you are varied.
Most scripting languages have methods for initiating outbound HTTP requests.

If you are using Microsoft ASP and Internet Information Server to host your website, you can use the
ServerXMLHTTP object that comes bundled with versions 3 and newer of the MSXML parser. The
MSXML parser is available as a free download from the Microsoft website.

After you have installed the MSXML parser, initiating a HTTP request is a straightforward process. If your
network uses a firewall, it will be necessary to allow your web server to make outgoing HTTP connections
to www.contentport.com.



Code Sample:
‘VBScript Sample

Dim HttpObj
Dim strURL
Dim strResult

‘create the object
Set HttpObj = Server.CreateObject("MSXML2.ServerXMLHTTP")

‘define the URL to request
strURL = "http://www.contentport.com/XMLOut/GetSSXML.asp?Site=ABC123&Account=contentTesting”

‘open the connection and send the request
HttpObj.Open "GET", strURL, False
HttpObj.Send

‘retrieve the resulting XML
strResult = HttpObj.ResponseText

‘load strResult into XML Parser and style

Set HttpObj = Nothing

Presenting the XML Data

There are a variety of methods that may be used to convert the data to a format suitable for display. You
can load the XML data into an XML parser for node-by-node manipulation, or you can use XSLT to
transform the XML.

Code Sample:
‘VBScript Sample – Displaying XML by looping through DOM

‘use previous code sample to retrieve XML and assign to strResult

Dim oXMLDom
Dim bLoadResult
Dim oNodeList
Dim oNode

Set oXMLDom = Server.CreateObject("MSXML2.DomDocument")
bLoadResult = oXMLDom.loadXML(strResult)

If bLoadResult Then

Set oNodeList = oXMLDom.selectNodes("/SiteSpecialData/Offer")

For Each oNode in oNodeList
Response.write(oNode.selectSingleNode("./OfferId").text)
Response.write(oNode.selectSingleNode("./Title").text)
Response.write(oNode.selectSingleNode("./StartDate").text)
Response.write(oNode.selectSingleNode("./LowAmount").text)
Response.write("<br>")
Next
End If

Set oXMLDom = Nothing

oesxyl
11-20-2009, 12:09 PM
I am very new to this and need some help with code for this. Please take it easy on me. By reading the webmasters guide for contentport. I guess it says im am trying to send a http request for xml data to be parsed and returned as html to be included in the main content div of my webpage. I believe the following examples in the webmasters guide are written for windows servers and i'm on linux. Do i need a perl script?
can you give more details about what do you want to achive?


Platform Type Debian
MySQL Version 5.0.77
Perl 5.8.8 and a bunch of installed modules
PHP 5.2.2

etch? lenny is already in stable.

best regards

landguy
11-20-2009, 01:18 PM
Contentport is a fictional address

• A customer visits the website.
• The website sends an HTTP request to the Contentport system.
• The Contentport system retrieves the requested Offer Group data from the database and returns them in XML format as the HTTP response.
• The website styles the XML data as necessary for display.

so it looks like
I need the code to make a http request
and then the code to style the xml data as html

Which scripting language would be best suited for http request with my
server technology?

And how would the code be written for trying to get a http request from?
http://www.contentport.com/xmlout/GetSSXML.asp?site=SiteCode&account=AccountCode

Making an HTTP Request

Depending on the server technology you use to host your website, the options available to you are varied.
Most scripting languages have methods for initiating outbound HTTP requests.

Then once the data is returned it needs to be presented to the enduser as html how would i go about this?

Presenting the XML Data

There are a variety of methods that may be used to convert the data to a format suitable for display. You
can load the XML data into an XML parser for node-by-node manipulation, or you can use XSLT to
transform the XML.

I don't believe i need node-by-node manipulation

oesxyl
11-20-2009, 01:47 PM
Contentport is a fictional address

• A customer visits the website.
• The website sends an HTTP request to the Contentport system.
• The Contentport system retrieves the requested Offer Group data from the database and returns them in XML format as the HTTP response.
• The website styles the XML data as necessary for display.

so it looks like
I need the code to make a http request
and then the code to style the xml data as html

Which scripting language would be best suited for http request with my
server technology?
this looks like wdsl:

http://www.w3.org/TR/wsdl

there are implemention for this in few languages including perl. You also need knowledge of xml/xslt and is a good idea to know javascript and ajax, json.


And how would the code be written for trying to get a http request from?
http://www.contentport.com/xmlout/GetSSXML.asp?site=SiteCode&account=AccountCode

Connection: close
Date: Fri, 20 Nov 2009 13:27:47 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Transfer-Encoding: chunked
Cache-Control: private
Content-Type: text/html; charset=utf-8

200 OK


Making an HTTP Request
that's simple but is not enought.


Depending on the server technology you use to host your website, the options available to you are varied.
Most scripting languages have methods for initiating outbound HTTP requests.

Then once the data is returned it needs to be presented to the enduser as html how would i go about this?

Presenting the XML Data
using xslt, but w3c have something more general in work, grddl:

http://www.w3.org/2004/01/rdxh/spec


There are a variety of methods that may be used to convert the data to a format suitable for display. You
can load the XML data into an XML parser for node-by-node manipulation, or you can use XSLT to
transform the XML.

I don't believe i need node-by-node manipulation
no you don't need but you need to provide information about data meaning and structure, a set of ontologies and some schema.
I'm afraid this field is pretty new and large with many experiments in last few years.

best regards

scrihumsti
12-09-2009, 09:07 PM
I accept with information:
Code Sample:
‘VBScript Sample

Dim HttpObj
Dim strURL
Dim strResult

‘create the object
Set HttpObj = Server.CreateObject("MSXML2.ServerXMLHTTP")

‘define the URL to request
strURL = "http://www.contentport.com/XMLOut/GetSSXML.asp?Site=ABC123&Account=contentTesting”

‘open the connection and send the request
HttpObj.Open "GET", strURL, False
HttpObj.Send

‘retrieve the resulting XML
strResult = HttpObj.ResponseText

‘load strResult into XML Parser and style

Set HttpObj = Nothing

Presenting the XML Data

There are a variety of methods that may be used to convert the data to a format suitable for display. You
can load the XML data into an XML parser for node-by-node manipulation, or you can use XSLT to
transform the XML.

Code Sample:
‘VBScript Sample – Displaying XML by looping through DOM

‘use previous code sample to retrieve XML and assign to strResult

Dim oXMLDom
Dim bLoadResult
Dim oNodeList
Dim oNode

Set oXMLDom = Server.CreateObject("MSXML2.DomDocument")
bLoadResult = oXMLDom.loadXML(strResult)

If bLoadResult Then

Set oNodeList = oXMLDom.selectNodes("/SiteSpecialData/Offer")

For Each oNode in oNodeList
Response.write(oNode.selectSingleNode("./OfferId").text)
Response.write(oNode.selectSingleNode("./Title").text)
Response.write(oNode.selectSingleNode("./StartDate").text)
Response.write(oNode.selectSingleNode("./LowAmount").text)
Response.write("<br>")
Next
End If

Set oXMLDom = Nothing


Thanks!
__________________



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum