MyOwnFreeHost API Client
#1
I released the code used to interface with the WHM API of MyOwnFreeHost on InfinityFree. You can now download, install and use it in your own projects.

You can view and download the code here: https://github.com/HansAdema/mofh-client
Owner of InfinityFree (formerly Grendel Hosting) and XVHOST.
  Reply
#2
How I integrate it with staria theme. It is a html theme with its own client area.

or can it be used with the WordPress site
Founder & Chief Executive Officer of GeekBiz,InnoxHost and NewsReload.
  Reply
#3
(03-20-2017, 01:19 AM)bachitter Wrote: How I integrate it with staria theme. It is a html theme with its own client area.

or can it be used with the WordPress site

It's an API client, not a full application. You can build your own client area using this library, a database and lots of additional code. This isn't the entire functionality of the InfinityFree client area, just a small but important component of it.
Owner of InfinityFree (formerly Grendel Hosting) and XVHOST.
  Reply
#4
(03-19-2017, 10:34 AM)Hans Wrote: I released the code used to interface with the WHM API of MyOwnFreeHost on InfinityFree. You can now download, install and use it in your own projects.

You can view and download the code here: https://github.com/HansAdema/mofh-client

Good Job. I wish I had this client when I started building MOFH based system.
  Reply
#5
trying to get help but can't find solution to create client area
Founder & Chief Executive Officer of GeekBiz,InnoxHost and NewsReload.
  Reply
#6
(03-21-2017, 12:09 AM)bachitter Wrote: trying to get help but can't find solution to create client area

How are you looking for the solution? Just Googling "how to create a client area"? Because that's not how it works. Client areas are complex web applications and how they work is highly dependent on your chosen technologies as well as the intended features.

A client area, on the basic level, is just a bunch of forms and a database with a login system in front of it. Those individuals components can be learned from guides and tutorials. However, integrating those to a coherent user experience cannot. Which data do you need to store? How will you gather it? How do you determine whether the data is valid? When can a user do what with the data.

All of these things, together commonly referred to as "business logic", are not explained through any tutorial, because they are unique to your application. Which means you need to figure them out yourself. However, you could look at https://infinityfree.net or https://profreehost.com/ for inspiration, if you want something like this.

A good start is to pick a web application framework and go through it's basic application tutorial, since it will teach you the most important base components. I personally use and love Laravel, which has great video tutorials available: https://laracasts.com/series/laravel-from-scratch-2017

But despite all of this inspiration, don't expect to be able to watch a 10 minute video and be ready. With your skill level, it's probably going to take you months of hard work in both learning and building in order to get something usable.
Owner of InfinityFree (formerly Grendel Hosting) and XVHOST.
  Reply
#7
Great contribution, Hans! This looks much more cleaner than what I'm currently using. Might implement it in my site.

I have a little question though: How would we display the "$response->result->statusmsg" or the "$response->result->options->vpusername" , for example?
Previously Tavoid on the YouHosting Forum
Feel free to PM me shall you need anything!
  Reply
#8
(03-22-2017, 11:22 PM)Orlando Wrote: Great contribution, Hans! This looks much more cleaner than what I'm currently using. Might implement it in my site.

I have a little question though: How would we display the "$response->result->statusmsg" or the "$response->result->options->vpusername" , for example?

The response handling has been completely encapsulated. If the statusmsg is set (meaning there is an error), it's recognized in the client and converted to an exception. In case of the username for create account specifically, it's returned as the function output. So you can do this:

PHP Code:
try {
 
   $username $api->createAccount(...);
} catch (
ApiException $e) {
 
   $statusmsg $e->getMessage();



Or you could catch the specific exception types (there are a lot, check the code) and use it to customize your error messages. But if you want, you can also read the entire response payload from the exception using $e->getOutput() (IIRC), but I only use it for logging purposes.
Owner of InfinityFree (formerly Grendel Hosting) and XVHOST.
  Reply
#9
Thanks for the Script Hans, im using it on my Website Big Grin
▁ ▂ ▄ ▅ ▆ ▇ █ Owner of OPHosting █ ▇ ▆ ▅ ▄ ▂ ▁
  Reply
#10
Hi Hans,

I'm having a little toruble in here. I'm using try/catch to handle error messages like you suggested, however, whenever there is a MOFH error, I get this:

Quote:Fatal error: Uncaught exception 'HansAdema\MofhClient\Exception\CreateAccount\DomainExistsException' with message 'The domain name sub.domain.tld is allready added to a hosting account. . ' in ...

which I suppose shouldn't be happening because I'm using try/catch.

I even tried to catch that specific exception to no avail.

Code:
try {
       $createacc = $api->createAccount(...);
       } catch (DomainExistsException $e) {
       $statusmsg = $e->getMessage();
       }

EDIT:

I solved it by using
Code:
       try {
       $createacc = $api->createAccount(...);
       } catch (HansAdema\MofhClient\Exception\ApiException $e) {
       $statusmsg = $e->getMessage();
       }
 I feel stupid but I'm leaving this here in case someone else faces such an error lol.
Previously Tavoid on the YouHosting Forum
Feel free to PM me shall you need anything!
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)