WINNER Help
[GUIDE] WINNER API for dummies (iOS app needed)
(1/1)
Steve
Hello, yourewinner.com still needs an app for iOS. Hopefully this quick guide for dummies can get you started!

yourewinner.com uses a slightly modified version of Tapatalk API, which is mostly documented HERE. Tapatalk uses a simple protocol called XML-RPC, which is mostly documented HERE.

Basically it works like this:
1) Send your XML document (via HTTP POST) to http://yourewinner.com/winnerapi/mobiquo.php
2) yourewinner.com will return an XML document containing the data you asked for
3) Parse the XML document in your app
4)

(note there are user-friendly xmlrpc libraries for most languages so you can avoid dealing with the XML completely)

Examples:

Method: login
Description: Logs you in
Required params: username (base64), password (base64)
Notes: any time the tapatalk docs say type is byte[], that means you have to base64 encode it

--- Code: ---
<?xml version="1.0"?>
<methodCall>
  <methodName>login</methodName>
  <params>
    <param>
        <value><base64>XXX69XX</base64></value>
    </param>
    <param>
        <value><base64>X69696XX</base64></value>
    </param>
  </params>
</methodCall>

--- End code ---

Curl command:

--- Code: ---
curl -c cookies.txt  -b cookies.txt -H "Content-Type: application/xml" -d @login.xml http://yourewinner.com/winnerapi/mobiquo.php

--- End code ---

Python3 (using xmlrpc library)

--- Code: ---
from xmlrpc.client import ServerProxy, Binary, Error

# see http://stackoverflow.com/questions/25876503/how-to-retain-cookies-for-xmlrpc-client-in-python-3
client = ServerProxy("http://yourewinner.com/winnerapi/mobiquo.php", CookiesTransport())

def login(username, password):
    # base64 encode parameters
    username = Binary(username.encode("utf-8"))
    password = Binary(password.encode("utf-8"))
    try:
        resp = client.login(username, password)
        return resp["result"]
    except Error as e:
        print("ERROR:", e)
        return False

--- End code ---

Method: get_latest_topic
Description: Returns a list of the latest topics ordered by date
Required params: start_num (int), end_num (int)
Notes: get_latest_topic(0, 9) returns first 10 topics

--- Code: ---
<?xml version="1.0"?>
<methodCall>
  <methodName>get_latest_topic</methodName>
  <params>
    <param>
        <value><int>0</int></value>
    </param>
    <param>
        <value><int>9</int></value>
    </param>
  </params>
</methodCall>

--- End code ---

Curl command:

--- Code: ---
curl -c cookies.txt -b cookies.txt -H "Content-Type: application/xml" -d @get_latest_topic.xml http://yourewinner.com/winnerapi/mobiquo.php

--- End code ---

Python3 (using xmlrpc lib)

--- Code: ---
from xmlrpc.client import ServerProxy, Binary, Error

# see http://stackoverflow.com/questions/25876503/how-to-retain-cookies-for-xmlrpc-client-in-python-3
client = ServerProxy("http://yourewinner.com/winnerapi/mobiquo.php", CookiesTransport())

def get_latest_topic(start, end):
    try:
        resp = client.get_latest_topic(start, end)
        # print username and short content
        for topic in resp["topics"]:
            msg = "{}: {}".format(resp["post_author_name"], resp["short_content")
            print(msg)
    except Error as e:
        print("ERROR:", e)

--- End code ---

Well that is pretty much everything you need to know to start making yourewinner.com app for iOS. Let me know if you have any questions. I am here to help 24/7
Dissident
I guess it wouldn't be a terrible opportunity to learn swift

I just hate dealing with xml ;_;
Steve
There's lots of libraries out there (which you should use) that handle the method calls for you and just give you a dictionary/map/whatever as the response. I was just demonstrating that it's pretty simple to implement yourself if necessary.

That's what yw.com app uses (shows how custom methods like "rate_post" are used)
https://github.com/steevp/YoureWinnerApp/blob/master/app/src/main/java/com/yourewinner/yourewinner/Forum.java

Found this one for Swift:
https://github.com/kodlian/AlamofireXMLRPC
Navigation
Message Index
Go to full version