YOUREWINNER.COM
 
   

[GUIDE] WINNER API for dummies (iOS app needed)
 
steev
#1 18-03-2017, 01:46:33 AM
  • Linux Gamer
  • Administrator
  • *****
    *****
    *****
    *****
    ***
  • Posts: 13631
  • Rigcoins: 888206.40
  • Send Money to steev
    Fedora Thumb Up
  • WINNERadminnovatorNostrasteevus+
  • "Be so good they can't ignore you! ❤️"
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) :winner:

(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: [Select]
<?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>

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

Python3 (using xmlrpc library)
Code: [Select]
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

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: [Select]
<?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>

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

Python3 (using xmlrpc lib)
Code: [Select]
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)

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


steevp
Dissident
#2 26-03-2017, 22:53:29 PM
  • the ultimate, the muffin man
  • *****
    *****
    *****
    *****
    *****
    *****
  • Posts: 17188
  • Rigcoins: 99966702.39
  • Send Money to Dissident
    OS X Puma Thumb Up
  • weeaboosexual orientation uncleardissident b shirt+
  • "smash the patriarchy"
I guess it wouldn't be a terrible opportunity to learn swift

I just hate dealing with xml ;_;




Dissident International Anti-Furry Organization
steev
#3 27-03-2017, 00:01:23 AM
- Last Edit: 27-03-2017, 00:09:16 AM
  • Linux Gamer
  • Administrator
  • *****
    *****
    *****
    *****
    ***
  • Posts: 13631
  • Rigcoins: 888206.40
  • Send Money to steev
    Fedora Thumb Up
  • WINNERadminnovatorNostrasteevus+
  • "Be so good they can't ignore you! ❤️"
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


steevp
0 Members and 1 Guest are viewing this topic.