SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2008
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing code from VB.NET to PHP

    I have an extremely simple code in VB.NET that I use to make cross-domain requests:


    Code VBNET:
    Imports System
    Imports System.Net
    Imports System.Xml
     
    Partial Class Feeds
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Response.ContentType = "text/xml"
    Dim feedUrl As String = Request.QueryString("feed")
    If (Not String.IsNullOrEmpty(feedUrl)) Then
    Dim document As XmlDocument = GetXmlFeed(feedUrl)
    Response.Write(document.OuterXml)
    End If
    End Sub
    Private Function GetXmlFeed(ByVal feedLocation As String) As XmlDocument
    Dim rssFeed As WebRequest = WebRequest.Create(feedLocation)
    Dim document As New XmlDocument
    Using Response As WebResponse = rssFeed.GetResponse()
    Using stream As System.IO.Stream = Response.GetResponseStream()
    document.Load(stream)
    End Using
    End Using
    Return document
    End Function
    End Class

    This code resides in the Feeds.aspx.vb page.


    Now, from the Default.aspx page I can basically make an asynchronous call to Feeds.aspx passing a web address in the querystring and return the content of the rss feed I'm interested in and displaying it in the default.aspx page.


    Everything works great when running the page in the VS 2005 or 2008, but I want to set the default.aspx page as home page (in browser), and using .aspx pages I can't...so I thought that if I'll use a .php page (Feeds.php) instead of Feeds.aspx and transforming the default.aspx into default.htm then I can set the default.htm as home page and run it under the XAMPP.

    Can anyone help me with transforming the VB.NET code to PHP, please?

    TIA.
    Proud member of this community.
    ____________________________

  2. #2
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP and .net languages are differents...so look at that .

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2008
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Dimis, but I've found my answer

    I've found this example:

    Code PHP:
    <?php
    header('Content-type: text/xml');
    require_once "HTTP/Request.php";
    $url = $_REQUEST['feed'];
    $req =& new HTTP_Request($url);
    if (!PEAR::isError($req->sendRequest())) {
        print $req->getResponseBody();
    }
    ?>

    It works exactly how I wanted!

    woohoo!! : )
    Proud member of this community.
    ____________________________


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •