SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 26/07/2018, 06:57 PM   #41
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,947
Reputation: 1510
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

I can't think of any advantages to creating a client for each player - you'd just create more work for you to maintain it.

As for JWT - absolutely, do that. Keep the auth secret safe, just like any application. There are plenty of tools for this such as Hashicorp's Vault or even consumer password managers like LastPass or encryption tools like Keybase (I run Keybase on my servers to safely share files and make use of their encrypted git repos).
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is offline   Reply With Quote
Old 11/08/2018, 02:26 PM   #42
XEGARE
Little Clucker
 
XEGARE's Avatar
 
Join Date: Oct 2017
Posts: 3
Reputation: 0
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Please help me. How to send an HTTPS request to a telegram server? (https://api.telegram.org/bot<token>/sendmessage?chat_id=%d&text=%s)
XEGARE is offline   Reply With Quote
Old 11/08/2018, 05:50 PM   #43
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,947
Reputation: 1510
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Create a new requests client with `https://api.telegram.org` as the base endpoint.

Make a POST request (or whatever their docs specify, it might be PUT) with that client using `/bot<token>/sendmessage?chat_id=%d&text=%s` as the path parameter.
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is offline   Reply With Quote
Old 11/08/2018, 07:24 PM   #44
XEGARE
Little Clucker
 
XEGARE's Avatar
 
Join Date: Oct 2017
Posts: 3
Reputation: 0
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Thank you so much. The thing was in the '/' wrong part of the query was
XEGARE is offline   Reply With Quote
Old 13/08/2018, 04:43 PM   #45
Kemula
Big Clucker
 
Join Date: Sep 2012
Posts: 101
Reputation: 1
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Really nice plugin! Using this for sure.

PS: Can we have some documentation for WebSockets and HTTPS requests?
Kemula is offline   Reply With Quote
Old 13/08/2018, 06:27 PM   #46
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,947
Reputation: 1510
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Just use `https` for HTTPS requests!

As for websockets, check the unit tests for an example. I will add some docs if I get time soon.
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is offline   Reply With Quote
Old 15/08/2018, 10:12 PM   #47
GRiMMREAPER
Huge Clucker
 
GRiMMREAPER's Avatar
 
Join Date: Jan 2018
Posts: 231
Reputation: 60
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

I absolutely love this plugin. Coming from Python and being a huge fan/user of requests and requests-html (did you get inspired by the earlier?), this is a gift from heaven.

To whoever comes across the situation where they have to access a JSON object inside an array (if you use OpenWeatherMap — see image— you'll run into this situation), this is the way to do it:

Code:
public OnGetJson(Request:id, E_HTTP_STATUS:status, Node:node) {
    new Node:weather;
    JsonGetArray(node, "weather", weather);

    new Node:element;
    JsonArrayObject(weather, 0, element);

    new weather_ID;
    JsonGetInt(element, "id", weather_ID);
    printf("id: %d", weather_ID); // Prints 800.
}



Thought I'd share this because I just started giving this plugin some use got stuck with this for a while. Regardless of that, great job on the plugin. Amazing.

Last edited by GRiMMREAPER; 20/08/2018 at 10:19 PM.
GRiMMREAPER is offline   Reply With Quote
Old 15/08/2018, 10:19 PM   #48
Kemula
Big Clucker
 
Join Date: Sep 2012
Posts: 101
Reputation: 1
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Quote:
Originally Posted by GRiMMREAPER View Post
I absolutely love this plugin. Coming from Python and being a huge fan/user of requests and requests-html (did you get inspired by the earlier?), this is a gift from heaven.

To whoever comes across the situation where they have to access a JSON object inside an array (if you use OpenWeatherMap *, you'll run into this situation), this is the way to do it:
...
Thought I'd share this because I just started giving this plugin some use got stuck with this for a while. Regardless of that, great job on the plugin. Amazing.
Lol, loving you right now! I was struggling my head with that same thing for a while!

Thanks
Kemula is offline   Reply With Quote
Old 20/08/2018, 10:19 PM   #49
GRiMMREAPER
Huge Clucker
 
GRiMMREAPER's Avatar
 
Join Date: Jan 2018
Posts: 231
Reputation: 60
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Quote:
Originally Posted by Kemula View Post
Lol, loving you right now! I was struggling my head with that same thing for a while!

Thanks
You are welcome!
GRiMMREAPER is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] SAMPSON - A JSON plugin for SA-MP KingHual Plugin Development 27 18/07/2018 03:26 PM
JSON and SAMP HTTP davidbull Scripting Help 0 05/09/2016 06:07 AM
[HELP] Vehicles.json don't load Stefand Scripting Help 1 21/02/2012 02:19 PM
HTTP() callback won't fire, + server crash using HTTP() KoczkaHUN Bug Reports 6 14/12/2011 09:35 AM
vehicles.json help plz sherlock Server Support 3 02/01/2011 12:41 PM


All times are GMT. The time now is 09:00 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.