SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast rgf207's Avatar
    Join Date
    Feb 2006
    Location
    Maryland
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to get information from remote server?

    I currently maintain 6 websites for clients that run small business. The websites use the same backend code. I'm looking for a way to gather information from these sites remotely and pass the information back to me so I don't have to manually go to each site to get the information. I can write a php script and place it in each of these sites that will gather the information and serialize it but I'm looking for a nice way to call these scripts from my site and log the data.

    For example; I could have the script reside on http://clients-web-site.com/script/getinfo.php. Would it be best to use cURL to call that script from my site and then parse the data on my end?

    Are there any other ways that would be better?

  2. #2
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,104
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    My vote goes with cURL. Have your remote data connection password protected and then use cURL locally and it will log in and retrieve the data.
    What I lack in acuracy I make up for in misteaks

  3. #3
    SitePoint Addict kduv's Avatar
    Join Date
    May 2012
    Location
    Atlanta, GA
    Posts
    244
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    +1 for cURL and password protection. I would also consider JSON for the data transportation. Additionally, you could compress the JSON with GZ or BZ to save bandwidth.

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,095
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    +1 for cURL

    I'd also put a .htaccess in the directory the file is in allowing access to your IP only.

    Code:
    order deny,allow
    deny from all
    allow from my.ip.add.res
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Enthusiast rgf207's Avatar
    Join Date
    Feb 2006
    Location
    Maryland
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tips. One more question. Can I pass the password (encrypted of course) to the remote script through cURL?

  6. #6
    SitePoint Member
    Join Date
    May 2012
    Posts
    6
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes, it can be done in the following manner:

    Code PHP:
    $curl = curl_init(); 
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ; 
    curl_setopt($curl, CURLOPT_USERPWD, "username:password");


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
  •