Comments (16)
Forgot to add the output in the omp-server.exe.
from pawn-requests.
Comigo acontece a mesma coisa ao tentar consumir uma api de clima.
from pawn-requests.
Are you saying that moving JsonGetObject(node, "privacy", privacy);
to another line causes the code to fail?
from pawn-requests.
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.
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.
this is weird. the same thing happens to me when trying to consume this api:
https://openweathermap.org/api
from pawn-requests.
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.
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.
Understandable. I'll wait then, thanks.
from pawn-requests.
@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.
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.
@The-Rett Show the json output so it can be tested to see what is happening.
from pawn-requests.
`
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.
@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.
Funcionou, obrigado.
from pawn-requests.
All good @ADRFranklin, he just forgot to deactivate the MainNode, thanks, it worked!
from pawn-requests.
Related Issues (20)
- Compile it for linux HOT 2
- sampctl package build / test - failed to compile package entry: exit status 3221226505 HOT 1
- Run time error 19: "File or function is not found" HOT 6
- Deprecate incorrectly named "Append" and implement "Push", "Concat" and "Merge"
- Docker on 32bit system HOT 2
- ERROR: HTTP error Error in SSL handshake HOT 1
- Error compiling on Ubuntu 14.04 HOT 5
- Error in SSL handshake HOT 2
- Russian characters in response HOT 2
- server crashed HOT 2
- randomly server freeze / crash HOT 1
- literal array/string passed to a non-const parameter error in Request functions
- JsonGetObject always failed "failed to parse response as JSON: ''" HOT 1
- Callback isn’t call in filterscript HOT 2
- Failed to create new HTTP client: provided uri is invalid HOT 1
- Plugin HOT 1
- Error HOT 2
- Plugin Error HOT 1
- libc.so.6: version `GLIBC_2.33' not found HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pawn-requests.