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- https://frappe.io/docs/user/en/guides/integration/rest_api

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 - https://frappe.io/docs/user/en/guides/integration/how_to_setup_token_based_auth

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?