Advanced Search

Results 1 to 9 of 9

Thread: XML Response Help Needed :(

  1. #1
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation XML Response Help Needed :(

    A Salute to all the dynamic drive members,
    I am a PHP-MySQL coder. I dont know much of XML. But all of a sudden I am asked to make use of an API and create a working script.

    I dont know how to get variables from XML. Kindly help me out. Kindly get me the below response in simple PHP variables also help me learn how you do it.

    Here Is What I have to work on :

    PHP Code:
    http://www.mobikwik.com/recharge.do?uid=<user_id>&pwd=<password>&cn=<cellNumber>&op
    =<operator_code>&cir=<circle_code>&amt=<recharge_amount>&reqid=<reqid>
    uid Member Id of retailer registered with mobikwik
    pwd 
    Password of the above retailer.
    cn Cell number to recharge
    op 
    Operator of cell number See Appendix)
    cir Circle of cell number See Appendix)
    amt Amount to recharge
    reqid 
    Request ID for this transactionIt should be a unique 20 digit number
    Sample Request 
    :
    http://www.mobikwik.com/recharge.do?uid=hemanta.gupta@gmail.com&pwd=password&cn=98
    12312345&op=1&cir=5&amt=50&reqid=12544172981250
    Sample success response
    :
    <
    recharge>
    <
    status>SUCCESS</status>
    <
    txId>12544172981250</txId>
    <
    balance>1000</balance>
    <
    discountprice>980</discountprice>
    </
    recharge>
    txId Indicates transaction id returned by mobikwik.
    balance Indicates current Mobikwik balance of the user
    With Regards

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    That's not XML except for this part:
    Code:
    <recharge>
    <status>SUCCESS</status>
    <txId>12544172981250</txId>
    <balance>1000</balance>
    <discountprice>980</discountprice>
    </recharge>
    If you can isolate that, you can use an XML function library (for example http://php.net/manual/en/book.simplexml.php) and work from there.
    If you can't isolate it or need to analyze all of that data, you'll need to use another approach.
    You could attempt regex (more direct, but more difficult) or use basic string functions if the data is predictable. For example, you could split it at each line break and work from there.

    The main point is that you need to control (limit and standardize) the amount/type of data output, then it will be much easier to work with it as input. If you can't control the output, your job will be more difficult (not to say impossible), but hopefully in that case the format is predictable (even if inconvenient).
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    I want to understand how did you get information about MobiKwik's API, because there is a legal/copyright issue associated with their API. And most importantly, are you even authorized to use it/sample it for a discussion in forums.

  4. #4
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    @djr33
    i understand that on calling the URL.. it returns the data in XML format...

    but how to process it. Do you mind giving a sample of it pls?

    a function that ud process this data n gimme in simple php variables?

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,629
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by shiprecked View Post
    I want to understand how did you get information about MobiKwik's API, because there is a legal/copyright issue associated with their API. And most importantly, are you even authorized to use it/sample it for a discussion in forums.
    I would assume maddyui is taking care of any legal issues.

    If you have some reason to suspect otherwise, I would suggest you address it more appropriately. Your comment reads like a wild, demanding accusation.

    You mention a "legal/copyright" issue, but you don't mention what it is, or why it's any of your concern. Likewise, do you have some authority to demand that maddyui proves they are authorized to use the api? If so, it might be more appropriate to deal with the issue privately.

    Quote Originally Posted by maddyui
    but how to process it. Do you mind giving a sample of it pls?
    did you look at the link djr gave? http://php.net/manual/en/book.simplexml.php
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  6. #6
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    @traq
    I have all legal rights to use their API. There is no way that their API is illegal in any aspect.
    Just for your confirmation you can check this :

    http://www.google.co.in/search?hl=en...=&oq=&gs_rfai=

    Yes I had a look at the link http://php.net/manual/en/book.simplexml.php
    but i got so confused roaming there. Can you be kind enough to give me a simple function for it?

    Thanks

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    Working with XML in PHP isn't simple. That's what you need to use, or another similar library. To use any of them, you need to be comfortable using classes. You can find tutorials for classes of course, and that's probably a good place to start, and also (if you look enough) probably tutorials for using XML in PHP-- with some examples. But there is no "simple" function that will do everything you need.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,629
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    How you would start depends on how the data is returned to you. Once you have it assigned to a php $variable, you can do something like this:
    PHP Code:
    $xmlString '<recharge><status>SUCCESS</status><txId>12544172981250</txId><balance>1000</balance><discountprice>980</discountprice></recharge>';
    $X = new SimpleXMLElement($xmlString);
    // assuming there is only one set of elements, 
    // and there is only one of each element,
    // you can access them directly fairly easily:
    print $X->status;  // prints "SUCCESS"
    // or assign them to variables
    $status $X->status;  // $status  holds value 'SUCCESS' 
    If you have more complex XML structures, or if you need to modify or re-save the XML tree, it gets significantly more complex.

    In addition, while you may be tempted to think of the SimpleXML Object ( $X in the example above) as a variable or an array, it is not. Objects are fundamentally different, and you'll run into problems fairly quickly if you don't read up and learn about how to handle them. SimpleXML is the easiest library I've used (far better than DomDocument), but it's isn't really "simple." As djr says, you need to have an understanding of how to use object-oriented PHP before this will make any sense to you.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  9. #9
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Dear MaddyUI,

    I am VP-Operations at MobiKwik.com and only affiliate(s)/affiliate teams authorized by me are allowed to carry out the API integration.

    At the same time, please confirm your client details. If you are not willing to share the information in a public forum, then mail your details to me at nikhil@mobikwik.com.

    Thanks

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
  •