Jump to content
  • 0
 Crytek

How to use top l2jbrasil API?

Question

private boolean isVotedInSite(String ip, VoteSite site)
    {
        try
        {
            // Make URL with vote site link with player IP address
            final URL url = new URL(site.getLink(ip));
            // Open connection
            final HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
            // Set User-Agent
            httpURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36");
            // Get response code and if everything is OK try to get answer
            final int response = httpURLConnection.getResponseCode();
            if (response == HTTP_OK)
            {
                // Get input stream from vote sites
                try (BufferedReader br = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream())))
                {
                    // Get answer from vote site which returns true/false
                    switch (site)
                    {
                        case L2HOPZONE:
                            return br.readLine().contains("true");
                        case L2TOPZONE:
                            return br.readLine().equals("TRUE");
                        case L2NETWORK:
                            return br.readLine().equals("1");
                        case L2TOP:
                            return br.readLine().equals("TRUE");
                        case L2BR:
                            return br.readLine().equals("1");    (if is correct or request correct read)
                    }
                }
            }

exampe of check is

 

https://top.l2jbrasil.com/votesystem/index.php?username=l2br&ip=0.0.0.0

 

have to get check of status. there is 1 (then player not voted is 0)

 

<votes><vote>

<site_id>id</site_id>

<ip>xxx.xx.xx.xx</ip>

<date>2017-04-24 19:34:07</date>

<status>1</status>

</vote></votes>

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0
Interesting, is this an in-game vote-reward?


Try change to



return br.readLine().equals("<status>1</status>");


or



return br.readLine().contains("<status>1</status>");


The return is a simple xml, may you can read it using DOM XML Parser


e.g.



doc.getElementsByTagName("status").item(0).getTextContent();

Optionally you can change the way you call to get another value than a xml response.



By node:

You can get the specific value using "node" parameter eg. &node=status will return only status value.




https://top.l2jbrasil.com/votesystem/index.php?username=l2br&ip=0.0.0.0&node=status



Json format:

To do that you must add paramter "&type=json"




https://top.l2jbrasil.com/votesystem/index.php?username=l2br&ip=0.0.0.0&type=json




  • Like 1

EJoOSOj.gif

Sua pergunta foi respondida? Certifique-se de marcar a resposta como a solução aceita.
Se existe mais de uma resposta, utilize o "vote up" para destacá-la.
Se você achar uma resposta útil, diga obrigado clicando no botão "Gostei".

Share this post


Link to post
Share on other sites

Proteja seu servidor de ataques DDoS massivos!

VPS EPIC
  • 0

 

Interesting, is this an in-game vote-reward?
Try change to
return br.readLine().equals("<status>1</status>");
or
return br.readLine().contains("<status>1</status>");
The return is a simple xml, may you can read it using DOM XML Parser
e.g.
doc.getElementsByTagName("status").item(0).getTextContent();
Optionally you can change the way you call to get another value than a xml response.
By node:
You can get the specific value using "node" parameter eg. &node=status will return only status value.
https://top.l2jbrasil.com/votesystem/index.php?username=l2br&ip=0.0.0.0&node=status
Json format:
To do that you must add paramter "&type=json"
https://top.l2jbrasil.com/votesystem/index.php?username=l2br&ip=0.0.0.0&type=json

 

Grundor, você poderia fazer funcionar e postar pra galera, ne

Seria interessante se tivéssemos um vote In-game do top 200 L2jbr.


"And I now wait to shake the hand of fate

Like the dusk awaiting dawn"

Share this post


Link to post
Share on other sites
  • 0

Grundor, você poderia fazer funcionar e postar pra galera, ne

Seria interessante se tivéssemos um vote In-game do top 200 L2jbr.

 

 

Complicado, cada distribuição tem sua forma de fazer as coisas, enquanto os servidores não tiverem "API" para interfacear direto com o servidor algumas coisas fica impossível fazer.

 

 

Essa api teria que ter o poder de atuar in-game em tempo real ao receber uma determinada chamada.


EJoOSOj.gif

Sua pergunta foi respondida? Certifique-se de marcar a resposta como a solução aceita.
Se existe mais de uma resposta, utilize o "vote up" para destacá-la.
Se você achar uma resposta útil, diga obrigado clicando no botão "Gostei".

Share this post


Link to post
Share on other sites
  • 0

Json api works correctly?, I'm creating a voting system and I include l2jbrasil but I don't know if this api really works, I put the parameters in username = the user with whom I register the server and in ip = the ip of the user with whom I perform the voting but it returns the default response "{" vote ": {" id ": {}," site_id ":" 0 "," ip ":" 0.0.0.0 "," date ":" 0 "," status ":" 0 "," server_time ":" 2020-05-02 06:04:29 "," hours_since_vote ":" - 1 "}}", am I doing something wrong?

Share this post


Link to post
Share on other sites
  • 0

image.pngYes, the API is working 😃


EJoOSOj.gif

Sua pergunta foi respondida? Certifique-se de marcar a resposta como a solução aceita.
Se existe mais de uma resposta, utilize o "vote up" para destacá-la.
Se você achar uma resposta útil, diga obrigado clicando no botão "Gostei".

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...



×
×
  • Create New...