webservice

Discussion in 'PHP' started by roice, Aug 28, 2012.

  1. #1
    Hello,

    I want to learn more about web services.

    I have a table: ID, name, phone
    How will be the code for program that send name+phone to the webservice and the webservice check if it exist or not in the DB

    Roi.
     
    roice, Aug 28, 2012 IP
  2. Web Solutions

    Web Solutions Peon

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    5
    Trophy Points:
    0
    #2
    Web service is a general term. What exactly are you referring to ?
     
    Web Solutions, Aug 28, 2012 IP
  3. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi there,

    Lets says that I have DB and I want to let other website/clients to make some queris in my DB, for that I need to build webservice
     
    roice, Aug 28, 2012 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #4
    You just need a script that they can call with the info they have and you then return it (normally as xml or plain text)

    eg

    www.mysite.com/getinfo.php?id=4543

    you then take 4543, query the database and return the info
     
    sarahk, Aug 28, 2012 IP
  5. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    So what you says is that I need to receive the variables in GET method?

    And - how do I send back the respond (the XML)?
     
    roice, Aug 29, 2012 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #6
    It doesn't have to be get but its simpler for the other site than post or soap, rest etc

    Look up php.net and find the headers for xml, then just use Php to output the text string that is really xml... Plain text might be easier, perhaps. Sounds like coding is a new skill so take it slowly.

    Only other issue is security, do you need to ensure you don't give the info to anyone who asks for it?
     
    sarahk, Aug 29, 2012 IP
  7. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    No, if yes I will add IP checks...(right?)

    Can you please write me a simple code for both files (the one that send and receive the request, and the one that create the query based on the request parameters) ?
     
    Last edited: Aug 29, 2012
    roice, Aug 29, 2012 IP
  8. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #8
    I don't think anyone should waste their time doing it for you.

    This is something you need to do for yourself. If you don't know how then you should pick up a book on programming and start to learn how to program. This is actually very easy to do.

    The easiest method would be to simply accept a HTTP POST to your script with the XML. Then parse the data, error check, run the database query, then return a response.
     
    NetStar, Aug 29, 2012 IP
  9. fastestsms

    fastestsms Greenhorn

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #9
    If your "web service" means somethings like "web service" from .NET... You should google for some jQuery + PHP example. That will help i think. :D
     
    fastestsms, Aug 30, 2012 IP