Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Retrieve data from a web api in json format Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Retrieve data from a web api in json format

Unread post by kev1n »

yvesf wrote: Thu May 12, 2022 4:02 pm curl_init() isn't recognized. Do I have to instanciate something ?
Error? Google?
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: Retrieve data from a web api in json format

Unread post by yvesf »

I know that it doesn't work because I have put it behind an input button under custom code, event onclick.
If I put onclick event the following code :

Code: Select all

$ch=curl_init();
nuMessage('test curl');
--> no message, the system is blocked on the first line.
If I put onclic event :

Code: Select all

$ch='test curl';
nuMessage($ch);
--> the message appears. I conclude that curl_init() isn't recognized. How can I retrieve the error msg ?
Many thanks for your help

Yves
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Retrieve data from a web api in json format

Unread post by kev1n »

You can't run PHP code in the browser. It has to be placed in a procedure.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Retrieve data from a web api in json format

Unread post by kev1n »

1. Add a Procedure with code e.g. retrieve_data

Builders -> Procedure -> Add
procedure.png


2. To run it, add this JS to a button's onclick event:

Code: Select all

nuRunPHPHidden('retrieve_data', 0);
You do not have the required permissions to view the files attached to this post.
Post Reply