SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2011
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    redirects vs cUrl

    Hello,

    I'm in a situation where my application needs to reach a remote server and grab some data from it. It only happens when a user submits a specific form on my website.

    Here's the flow:

    1) User submits form
    2) Reach remote server
    3) Get some data
    4) Use that data

    I can trust remote server. So I was wondering if it would be ok to simply do the following:

    1) User submits form
    2) Redirect to remote server
    3) Remote server redirects to original server with data appended to url (query string)
    4) Use that data

    Or would it be better to do the following:

    1) User submits form
    2) cUrl request server
    3) Get data
    4) Use that data

    What are the advantages of each approach (cUrl vs redirects)?


  2. #2
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Use the latter, the former is just ghetto.

    Also I don't know what kind of data is coming back, but at the minimum, using cURL means it won't be as easy to mess with.

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I think the latter would mean you could handle any failure to load the site/data better, and manage a time-out more gracefully.


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
  •