Thread: Webservice

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    kerala
    Posts
    72
    Rep Power
    2

    Webservice


    Hi,

    How we can communicate and transfer datas from different servers with different protocols using php? Please help me.

    Example: I have two websites
    www.sample1.com and www.sample2.com. They are hosted in different servers. How can i get datas from www.sample2.com to www.sample1.com.

    Regards
    Sarath_PHP
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,454
    Rep Power
    594
    PHP is intended to exchange information between a client (browser) and a server (http). PHP does not sound like the tool for this (server to server). Please clarify what you are trying to accomplish.

    Comments on this post

    • dmittner disagrees : PHP is fine for a server-to-server connection. In fact, a thin PHP presentation layer relaying requests to a backend API is probably one of it's most optimal uses.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,985
    Rep Power
    375
    to get data from another server.. you could

    1. file_get_content(url);
    2. the other servers API/Webservice..

    its the same as if we wanted to work with locations we might use google's API to get data from google,
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Location
    Vancouver, WA, USA
    Posts
    397
    Rep Power
    189
    Without knowing what you are trying to do, I cannot answer completely.

    That being said, there are multiple methods of reading data from one site into another, but which one, will depend on your needs. These are only examples, and certainly do not constitute a complete list.

    1) Share a mySQL database between both sites.
    2) Write an API (background access points) using PHP for one site to get info from the other on the fly. (PHP and/or AJAX)
    3) Capture (scrape) a page from other site using something like file_get_contents or cURL

    You can use PHP to capture a variety of formats of data, including RRS, HTTP, HTTPS, FTP, XML, XHTML, CSV, JSON, and so many more.. Even custom formats.

    Not all methods are available on all web hosts.

    It really comes down to your needs. Do you need to grab data on the fly, sync data in the background, or have both sites with current data at all times? With some of these, you may run into trouble if one site goes down, and the other cannot reach it at the moment the visitor wants data, especially if the two sites are on different servers, or even in different datacenters.

    Your application may also have security measures you need to keep aware of.
    Thomas Tremain
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    kerala
    Posts
    72
    Rep Power
    2
    Originally Posted by ttremain
    Without knowing what you are trying to do, I cannot answer completely.

    That being said, there are multiple methods of reading data from one site into another, but which one, will depend on your needs. These are only examples, and certainly do not constitute a complete list.

    1) Share a mySQL database between both sites.
    2) Write an API (background access points) using PHP for one site to get info from the other on the fly. (PHP and/or AJAX)
    3) Capture (scrape) a page from other site using something like file_get_contents or cURL

    You can use PHP to capture a variety of formats of data, including RRS, HTTP, HTTPS, FTP, XML, XHTML, CSV, JSON, and so many more.. Even custom formats.

    Not all methods are available on all web hosts.

    It really comes down to your needs. Do you need to grab data on the fly, sync data in the background, or have both sites with current data at all times? With some of these, you may run into trouble if one site goes down, and the other cannot reach it at the moment the visitor wants data, especially if the two sites are on different servers, or even in different datacenters.

    Your application may also have security measures you need to keep aware of.
    Thanks for your reply

    I have two website (www.server1.com and www.server2.com). They are hosted in different servers.

    My purpose is collect 500 products details from server2 database and store in to server1 database. Please help me.

    Thanks
    SarathPHP
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    kerala
    Posts
    72
    Rep Power
    2

    Webservice


    Dear Professionals,

    I have two website (www.server1.com and www.server2.com). They are hosted in different servers.

    My purpose is collect 500 products details from server2 database and store it in to server1 database with the help of webservice. Please help me.

    Thanks & Regards
    SarathPHP
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    80
    Rep Power
    3
    Hi,

    Simply export the database using phpmyadmin from server 2, and import it into server 1...

    If you require some help, just ask.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    56
    Rep Power
    0
    Is this Right way to transfer the data one server to other server?
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    80
    Rep Power
    3
    Presuming they are both using the same script then yes this will work, but, back up both database's first, just in case something fails.

    Or if you are using cpanel/directadmin, use the import/transfer script
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    kerala
    Posts
    72
    Rep Power
    2
    Originally Posted by private_html
    Hi,

    Simply export the database using phpmyadmin from server 2, and import it into server 1...

    If you require some help, just ask.

    Thanks for you reply

    First time this is ok. Please assume some products price has changed in server2 so how will we get the update in server 1. So webservice is fine for this purpose. But i don't know how to apply webservice.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    kerala
    Posts
    72
    Rep Power
    2
    Originally Posted by barclaysbensons
    Is this Right way to transfer the data one server to other server?

    Thanks for your reply.

    Yes of course this is the wright way.

    Eg: www.one.com and www.two.com, these are two domains and hosted in different servers.

    My second website contains 500 products. I need some products details from second website in to my first website. So i heard about webservice is the best option, but i don't know how to apply.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Location
    Vancouver, WA, USA
    Posts
    397
    Rep Power
    189
    Originally Posted by Sarath_PHP
    Thanks for your reply

    I have two website (www.server1.com and www.server2.com). They are hosted in different servers.

    My purpose is collect 500 products details from server2 database and store in to server1 database. Please help me.

    Thanks
    SarathPHP
    In what way are you looking for help?

    If you are interested in hiring someone, you can PM me.
    Thomas Tremain
  24. #13
  25. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by Sarath_PHP
    I have two website (www.server1.com and www.server2.com). They are hosted in different servers.

    My purpose is collect 500 products details from server2 database and store in to server1 database.
    First, a key point: A website and a database, though one connects to the other, are independent things. The database used on server2 can be connected to by anything--not just the server2.com website.

    That said, all you should need is a script that connects to both databases, loads the data from database2, and inserts the data in database1.

    Or if this is a one time data copy, you don't even need PHP. You can do a mysqldump/export of database2's data and import it directly into database1.
    LinkedIn: Dave Mittner
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    kerala
    Posts
    72
    Rep Power
    2
    Originally Posted by ttremain
    In what way are you looking for help?

    If you are interested in hiring someone, you can PM me.


    Iam looking for, with the help of web service, collect products details from www.server2.com and store or display in to www.server1.com.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    kerala
    Posts
    72
    Rep Power
    2
    Originally Posted by dmittner
    First, a key point: A website and a database, though one connects to the other, are independent things. The database used on server2 can be connected to by anything--not just the server2.com website.

    That said, all you should need is a script that connects to both databases, loads the data from database2, and inserts the data in database1.

    Or if this is a one time data copy, you don't even need PHP. You can do a mysqldump/export of database2's data and import it directly into database1.


    Thanks for your reply.

    How should connect different database using php. Because database are hosted in different server.



    My purpose is, with the help of web service, collect products details from www.server2.com and display or store in to www.server1.com.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo