Giter VIP home page Giter VIP logo

Comments (16)

pushline avatar pushline commented on August 26, 2024

Forgot to add the output in the omp-server.exe.

image

from pawn-requests.

rettdev avatar rettdev commented on August 26, 2024

Comigo acontece a mesma coisa ao tentar consumir uma api de clima.

from pawn-requests.

Southclaws avatar Southclaws commented on August 26, 2024

Are you saying that moving JsonGetObject(node, "privacy", privacy); to another line causes the code to fail?

from pawn-requests.

pushline avatar pushline commented on August 26, 2024

Are you saying that moving JsonGetObject(node, "privacy", privacy); to another line causes the code to fail?

Yeah. If I put in the top, i cannot obtain the rest of the JSON. Only the privacy indexes.

from pawn-requests.

Southclaws avatar Southclaws commented on August 26, 2024

Hmm that is very odd, I can't see any field mutations going on in the getter https://github.com/Southclaws/pawn-requests/blob/master/src/natives.cpp#L489-L515 any idea @ADRFranklin ?

from pawn-requests.

rettdev avatar rettdev commented on August 26, 2024

this is weird. the same thing happens to me when trying to consume this api:

https://openweathermap.org/api

from pawn-requests.

pushline avatar pushline commented on August 26, 2024

I'll do some tests tonight changing the order. Will put the code + output in imgur, just to not put so many pics here.

from pawn-requests.

ADRFranklin avatar ADRFranklin commented on August 26, 2024

I noticed this issue a while ago, when rewriting my geoip library, it seems in some cases it's not able to find the fields in the extracted and parsed json results. I never found time to debug it, and I don't currently have the time to debug it now.

If no one else is able to debug it, then you'll have to wait for me to get some free time.

Also I am linking my geoip library as I think it's more beneficial to you then what you have.
http://sharex.justmichael.xyz/fAFE9/XUBANAHi29.txt

from pawn-requests.

pushline avatar pushline commented on August 26, 2024

Understandable. I'll wait then, thanks.

from pawn-requests.

ADRFranklin avatar ADRFranklin commented on August 26, 2024

@pushline after further investigation, it turns out that you need to turn off garbage collection for the initial node, as the second node you create causes the first one to be garbage collected and removed. So simply adding JsonToggleGC and setting the value to false after creating the node and then at the end of the function when done with it, toggle the gc back on.

forward OnGetAntiVPN(Request:id, E_HTTP_STATUS:status, Node:node);
public OnGetAntiVPN(Request:id, E_HTTP_STATUS:status, Node:node)
{
    switch(status){
        case HTTP_STATUS_OK:{
            new Node:asn, Node:org, Node:privacy;
           JsonToggleGC(node, false);

            new playerid = targetPLAYER;
          
            JsonGetObject(node, "privacy", privacy);
            JsonToggleGC(privacy, false);

            JsonGetBool(privacy, "vpn", User[playerid][VPN]);
            JsonGetBool(privacy, "proxy", User[playerid][Proxy]);

            JsonGetString(node, "city", User[playerid][City]);
            JsonGetString(node, "country", User[playerid][Country]);
            JsonGetString(node, "timezone", User[playerid][TimeZone]);
            JsonGetString(node, "postal", User[playerid][Zip]);
            
            JsonGetObject(node, "asn", asn);
            JsonToggleGC(asn, false);
            JsonGetString(asn, "name", User[playerid][Isp]);

            JsonGetObject(node, "company", org);
            JsonToggleGC(org, false);
            JsonGetString(org, "name", User[playerid][Org]);
        
            printf("vpn %s", User[playerid][VPN] ? "true" : "false");
            printf("proxy %s", User[playerid][Proxy] ? "true" : "false");

            printf("city %s", User[playerid][City]);
            printf("country %s", User[playerid][Country]);
            printf("timezone %s", User[playerid][TimeZone]);
            printf("postal %s", User[playerid][Zip]);
            printf("isp %s", User[playerid][Isp]);
            printf("org %s", User[playerid][Org]);

            JsonToggleGC(privacy, true);
            JsonToggleGC(asn, true);
            JsonToggleGC(org, true);
            JsonToggleGC(node, true);
        }
        default: printf("%s", E_HTTP:STATUS:status);
    }
    return 1;
}

Please give this a test and tell me if this works for you?

from pawn-requests.

rettdev avatar rettdev commented on August 26, 2024
function OnGetJsonWeather(Request:id, E_HTTP_STATUS:status, Node:node){
    switch(status){
        case HTTP_STATUS_OK:{
            new Node:MainNode = node;
            //----------------------- MAIN ---------------------------------//
            JsonGetObject(MainNode, "main", g_Weather[nodeTemp]);
            JsonToggleGC(g_Weather[nodeTemp], false);
            JsonGetFloat(g_Weather[nodeTemp], "temp", g_Weather[TempWeather]);
            JsonGetFloat(g_Weather[nodeTemp], "temp_min", g_Weather[TempWeatherMin]);
            JsonGetFloat(g_Weather[nodeTemp], "temp_max", g_Weather[TempWeatherMax]);

            //----------------------- SYS AND NAME ---------------------------------//
            JsonGetObject(MainNode, "sys", g_Weather[nodeSys]);
            JsonToggleGC(g_Weather[nodeSys], false);
            JsonGetString(g_Weather[nodeSys], "country", g_Weather[CountryWeather]);
            JsonGetString(node, "name", g_Weather[CityName]);

            //----------------------- WEATHER ---------------------------------//
            JsonGetObject(MainNode, "weather", g_Weather[nodeWeather]);
            JsonToggleGC(g_Weather[nodeWeather], false);
            JsonArrayLength(g_Weather[nodeWeather], g_Weather[WeatherLength]);
            
            for(new i = 0; i < g_Weather[WeatherLength]; i++) {
                new Node:weatherNode;
                JsonArrayObject(g_Weather[nodeWeather], i, weatherNode);
                JsonGetString(weatherNode, "main", g_Weather[WeatherName]);
            }

            JsonToggleGC(g_Weather[nodeTemp], true);
            JsonToggleGC(g_Weather[nodeSys], true);
            JsonToggleGC(g_Weather[nodeWeather], true);

            printf("weather=%s, temp=%.0f°C, temp_min=%.0f°C, temp_max=%.0f°C, cityname=%s, country=%s", g_Weather[WeatherName], g_Weather[TempWeather], g_Weather[TempWeatherMin], g_Weather[TempWeatherMax], g_Weather[CityName], g_Weather[CountryWeather]);
        }
        default: printf("ERROR: OUTPUT %i", Float:status);
    }
    return 1;
}

output:
weather=, temp=285°C, temp_min=283°C, temp_max=288°C, cityname=, country=

from pawn-requests.

ADRFranklin avatar ADRFranklin commented on August 26, 2024

@The-Rett Show the json output so it can be tested to see what is happening.

from pawn-requests.

rettdev avatar rettdev commented on August 26, 2024

`
printf("status=%i, weather=%s, temp=%.0f°C, temp_min=%.0f°C, temp_max=%.0f°C, cityname=%s, country=%s", _:status, g_Weather[WeatherName], g_Weather[TempWeather], g_Weather[TempWeatherMin], g_Weather[TempWeatherMax], g_Weather[CityName], g_Weather[CountryWeather]);

status=200, weather=, temp=285°C, temp_min=283°C, temp_max=288°C, cityname=, country=
`

from pawn-requests.

pushline avatar pushline commented on August 26, 2024

@ADRFranklin I changed my API for the IP thing cause I couldn't retrieve the proxy/vpn parts cause they need to be paid.
It worked normally with custom IPs, thanks.

@The-Rett as I saw in Franklin's example u need to aswell desactivate the MainNode before everything and after the child ones.

from pawn-requests.

rettdev avatar rettdev commented on August 26, 2024

Funcionou, obrigado.

from pawn-requests.

pushline avatar pushline commented on August 26, 2024

All good @ADRFranklin, he just forgot to deactivate the MainNode, thanks, it worked!

from pawn-requests.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.