ERPNext + PHP Company Website

Good Day

We have a PHP Company website and would like to know what best way to read data from ERPNext to display on website via restapi?

Is this wrapper i can use:

Or there better way as i see this was updated 4 years back.

Thank You

Albertus Geyser

1 Like

You can hit the ERPNext - api directly from javascript itself. Or if you would like to user php, you can use Guzzle to connect to the frappe/ERPNext api. Please refer for more info about the api and how to connect to it- Introduction

1 Like

Thank You

Will check it out and if you do not mind ask questions here.

Sure. No problem. Cheers.

Do not have any javascript example code i can go through to understand better?

Thank You

Would be great if i can see how to login and do get and post if possible.

Thank You

Please refer - Token based authentication

Let me know, if you are still struggling, I will help you in connecting to the api.

Good Day

I tried the following Simple Authentication:

var request = $.ajax({
url: ā€˜https://xxx.xxx.xxx.xxx/api/method/loginā€™,
type: ā€˜POSTā€™,
data: { usr: ā€œUsernameā€, pwd : ā€œPasswordā€} ,
contentType: ā€˜application/jsonā€™
});

request.done(function(data) {
alert(ā€œDoneā€);
});

request.fail(function(jqXHR, textStatus) {
alert(ā€œFailedā€);
});

But fails.

Any help?

Thank You

Good Day

I tried the following without any success:

$.ajax({
url: ā€˜http://xxx.xxx.xx.xx/api/method/loginā€™,
method: ā€˜POSTā€™,
data: {usr: ā€œUserā€, pwd : ā€œPasswordā€},
dataType:ā€œjsonā€,
contentType: ā€œapplication/jsonā€,
accepts:ā€œapplication/jsonā€,
success: function(data) {
alert(data);

},
error: function(data, errorThrown){
	alert("Login " + errorThrown);
}

});

Good Day

Still nobody that did this before?
I really need help regarding javascript + RestAPI.

Thank You
Albertus Geyser

where should upload php files from other sites?