+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Mar 2005
    Posts
    93

    Red face PHP - XML - "API"?

     
    Hello TechIMO users,

    I need to test the communication between several workstations using a browser, with what I call right now an "API".

    Here's what I've done so far:
    USING PHP
    1) Upload a picture form. Write a name for the picture
    2) When user uploads the picture, the app renames the file to the one given by the user, and then generates an XML with the name of the file, the ip of the workstation, and the image itself in base64.
    3) The XML is saved on a /xml folder with "name.xml"
    4) The image is saved on a /image folder with "name.xxx" (xxx = jpg, gif...etc)

    The PHP shows (after submission):
    - XML content
    - name an folders where the files were saved.


    SO... Now the "API" comes to work, and this is where I am stuck...

    5) The PHP app should alert the "API" to pick up the /xml/name.xml .
    6) The "API" should read the alert, and pick up the file.
    7) The "API" will check the xml, if it is "understandable" and then return a "Flag" to the PHP app
    8) The PHP app should display in the screen, the response of the "flag" after showing the XML content.


    So, my questions are:
    a) Should I use PHP as the "API"? I tried with http-request but I noticed it is now disabled in PHP 5.3.1
    b) What other programming language do you suggest?
    c) If this is not an "API" how would you call it?
    Keep in mind that the "API" receives an xml, and returns a positive or negative answer, but doesn't interact directly with the user.


    Thank you all for your valuable help!!!

  2. #2
    Ultimate Member quickoldcar's Avatar
    Join Date
    Oct 2004
    Location
    NE Pennsylvania
    Posts
    1,005
    Blog Entries
    1
    Sometimes simpler is better, How about this.

    Do a check ifexists using php, if it does exist then display xml content, if content is true then task completed and display or whatever want to do with it from there.
    $filename = "wherever get unique filename from or the variable for it";
    $xml_filename = "./xml/$filename.xml";
    if (file_exists($xml_filename)) {
    $xml_exists = $xml_filename;
    } else {
    $xml_exists = "some alternate message or file location";
    }

    Just some fast code, should do what you need, you can add even more ifexists or even set temporary expected file locations as variables prior to checking, and check those as well.
    Last edited by quickoldcar; September 14th, 2010 at 01:56 AM.
    DynaIndex.com - Dynamic search index of websites, links, feeds, title, description, keywords and thumbnail snapshot.

  3. #3
    Ultimate Member quickoldcar's Avatar
    Join Date
    Oct 2004
    Location
    NE Pennsylvania
    Posts
    1,005
    Blog Entries
    1
    You can use curl in php to check for that file across servers, forgot to mention that.

    Curl seems the most flexible and reliable to me.
    DynaIndex.com - Dynamic search index of websites, links, feeds, title, description, keywords and thumbnail snapshot.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. T'isnt a "massage"! Its "the religious act of "laying on of hands"
    By no1_vern in forum DebateIMO: Politics, Religion, Controversy
    Replies: 3
    Last Post: September 29th, 2008, 08:29 PM
  2. [PHP] Creating "if" Statement for Email Form
    By Cody in forum Webmastering and Programming
    Replies: 2
    Last Post: August 8th, 2006, 06:28 PM
  3. How do I disable the "power", "sleep", and "wake" buttons.
    By ShawnD1 in forum General Tech Discussion
    Replies: 1
    Last Post: January 30th, 2004, 11:50 AM
  4. Remember the "Worm", "Cave", or "Ribbon" games?
    By SickPup404 in forum IMO Community
    Replies: 11
    Last Post: July 10th, 2002, 07:02 PM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews