SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Sending data to third-party server then retrieving data back from third-party server

    Is this possible within PHP:

    1. User fills in form on my site
    2. The form submits the data from the form to a third-party server somewhere else on the net, essentially handing off the data to the third-party server somehow
    3. Said third-party server does something with the data and then generates a numerical value to send back to my PHP script
    4. My server/PHP script gets that numerical value/data for use in the script again

    Is it doable in PHP? Does PHP have inbuilt functions to perform the above tasks? Would such a thing require tons of advanced code or is it relatively easy to do?

    Thanks in advance for any help on the matter

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One quick question to you first:
    Do the another third party server/site is also under your control? I mean you are the one to develop the script in third party server/site too? If yes then you can do it by using PHP but wouldn't say that easier and neither that difficult to. If you have control of third party server too then have a look at PHP Curl. Or see some examples i.e.:
    http://coderscult.com/php/php-curl/2...h-curl-in-php/
    http://davidwalsh.name/curl-post
    http://www.askapache.com/php/sending...-php-curl.html

    If you are not the one to handle the script in third party then they (third party) should have provided some information/manual on how to send the data from your site to their site. Generally we call it WebService to send/share information between two servers. Depending upon the third party's way of receiving data, you would need to learn/see some code in PHP accordingly.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The third-party server would have to specify how we connect with them. Assuming they have a way to let us connect, is it possible to do what i've proposed using PHP to send the data to them and then receive the data back off them once they send it back to us?

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes that is quite possible but the "how" would depend on their way of receiving & sending back data.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  5. #5
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raju Gautam View Post
    Yes that is quite possible but the "how" would depend on their way of receiving & sending back data.
    Im looking to do the same thing, but I have to do 2 queries, 1 to get a "session key" from their site that is then used in the second query to lookup the data.
    I already do this in ColdFusion, but I need to in PHP (Joomla!). PHP extreme-noob here.

    The 2 queries I use in CF are (with specific data XXX'd out and opening < 's removed ):

    #get session key

    cfset urlAddress="http://www.XXXXXXXX.com/xml?username=XXXXX;password=XXXXXXXXXX;agent=q5.0">
    cfhttp url="#urladdress#" method="GET" resolveurl="Yes" throwOnError="Yes"/>

    cfset sitekey=item.Key.xmltext>

    #/get session key

    THEN

    #query data

    cfset urlAddress="http://www.XXXXXX.com/xml?s=#sitekey#;username=#user-var#">
    cfhttp url="#urladdress#" method="GET" resolveurl="Yes" throwOnError="Yes"/>

    cfset xmlDoc = XmlParse(CFHTTP.FileContent)>
    cfset resources=xmlDoc.xmlroot.xmlChildren>
    cfset numresources=ArrayLen(resources)>
    cfset item=resources[1]>

    cfset newusername = ("item.username.xmltext")>

    .....etc etc etc.....

    #/query data

    I would hope as good as PHP is, this would be fairly simple, but again, Im just starting the dive into PHP.

    Thanks
    Jim


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
  •