#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Adelaide, South Australia
    Posts
    15
    Rep Power
    0

    Working with an API / PHP


    Hey Guys,

    I'm a newbie here so be nice

    I've got a fair background in website development and most PHP stuff I can work out but I seem to be struggling with working this issue out. There's a billing system that i'm using and I'm trying to create an invoice using PHP via their API

    EDIT: Because I'm a "new user" i cant make posts containing urls so...

    The Billing system is called XERO the api info is here:

    blog . xero . com / developer / api / Invoices /
    blog . xero . com / developer / getting-started / code / php /

    I've honestly been hitting my head against a wall with this one, I know their API spits things out in XML but I just can't work my head around how to have a HTML form with input fields that "POST"s to their API.

    Would someone be able to give me a hand in plain english please?


    Thanks in advance
    Ben
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    Without looking at the API itself (I'm hungry and tired) you probably aren't supposed to use an HTML form to interact with it. Even less likely if they use XML.

    You're supposed to have PHP talk to it. Like with cURL or SOAPClient, for example. If you need an HTML form then go ahead and have one, but it posts back to your own server, the receiving PHP script pieces together the request to the API accordingly, and deals with its response.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Adelaide, South Australia
    Posts
    15
    Rep Power
    0
    Originally Posted by requinix
    Without looking at the API itself (I'm hungry and tired) you probably aren't supposed to use an HTML form to interact with it. Even less likely if they use XML.

    You're supposed to have PHP talk to it. Like with cURL or SOAPClient, for example. If you need an HTML form then go ahead and have one, but it posts back to your own server, the receiving PHP script pieces together the request to the API accordingly, and deals with its response.
    Thanks for your reply requinix,

    Yeah that's what I gathered, one of those links i posted above is a PHP file that someone's written which I'm guessing will do the talking directly to the Xero API, I'll just make an html form that submits the correct variables to the PHP file.

    I'll post back if i get stuck with any other things. Thanks again

IMN logo majestic logo threadwatch logo seochat tools logo