hostronavt Posted July 20, 2019 Share Posted July 20, 2019 (edited) Hi there! We are the best free hosting in Russia, and we understood that WHM API is really poor, so ... We have created a php library, that connects to MyOwnFreeHost panel and interacts with it. Check it with documentation at https://github.com/hostronavt/mofh-client I'm waiting for comments Edited July 20, 2019 by hostronavt Quote Link to comment Share on other sites More sharing options...
InfinityFree Posted July 21, 2019 Share Posted July 21, 2019 Why do you think the WM API is so poor? Or at least, why do you think a web scraper is better? Sure, the reseller panel has a few more options than the API, and the output of the API is not always very consistent. But a web scraper sounds like it would suffer from these same issues but worse. APIs are at least designed to have consistent output for programmatic access, a guarantee you don't get with a web interface. iFastNet has a habit of making major changes without any notice (before or after), which would break your client completely. As for your client itself, there are a few things which I would like to see or do differently: Make it possible to pass a cookie jar to the client. You currently require a login request for every time a client instance is created, which requires a round trip to the API, which adds a lot of overhead to the web transaction this client is used in. In a production workload where you have a large volume of API calls, persisting and reusing the cookies in some kind of cache (configurable by the developer, hence the cookie jar implementation) will helps prevent MANY unnecessary calls to the panel and speed up your website. For inspiration, check how cookies are done with Guzzle. Speaking of Guzzle: try it if you haven't already. It's great, much easier to use than curl_*. Which would be easy to use if combined with... Composer. The best way to manage dependencies and class loading in PHP. Learn it, add support for it, your life will never be the same. Another case of unnecessary HTTP calls: don't fetch the statistics every time after login. You don't need them every time, and now you're adding dozens of ms to every page load to get data which you may not need. This should be a separate API call. Generally messy management of internal state. A good class should not require that implementations calls methods on that class in a specific order. If they do, that's typically a sign that your class boundaries are wrong. A good example is the Client::set function. You must create the client object first and then you MUST call this method first before you can use any of the other methods. Changing that to a constructor makes the class more fool proof and reduces the need for checks to make sure the set method was called first. Speaking of internal state: most coding style guides demand that all object variables should be defined on the class, and not created on runtime. You set most values that way (except for a few booleans which determine whether these values were set - why not check the values themselves?). Many functions have weird specs or don't do what I would expect them to do. I would change "initialize" to "login" (because logging in to the panel is what it does). "changePassword" changes the reseller password, not the user password. If findUsers has as first argument a string which has to be one of three hard coded values, why not create separate methods? Quote Link to comment Share on other sites More sharing options...
hostronavt Posted July 21, 2019 Author Share Posted July 21, 2019 4 minutes ago, InfinityFree said: Why do you think the WM API is so poor? Or at least, why do you think a web scraper is better? Just because when I need client's email, I don't have any opportunity to get it in another way... 5 minutes ago, InfinityFree said: As for your client itself, there are a few things which I would like to see or do differently Okey, yeah, I see that there are problems in my code and it needs a lot of changes, thank you for you suggestions. But, summing up, this is better than nothing? Quote Link to comment Share on other sites More sharing options...
hostronavt Posted July 21, 2019 Author Share Posted July 21, 2019 28 minutes ago, InfinityFree said: "changePassword" changes the reseller password, not the user password. I thought it's logical when you call $panel->changePassword(); that it would change reseller password Who can also comment our work?)) Quote Link to comment Share on other sites More sharing options...
hostronavt Posted July 21, 2019 Author Share Posted July 21, 2019 Made some changes, thanks to @InfinityFree. Now script checks if cookie is valid and if it does doesn't login one more time. If you need reseller statistics variables, call Panel::getStatistics function first. It is for decreasing script running time. Now you don't have to initialize Panel and Client, just do like this: $panel = new Panel($login, $password); $client = new Client($panel, $user); Waiting for next reviews Latest version on https://github.com/hostronavt/mofh-client Quote Link to comment Share on other sites More sharing options...
Geenzo Posted March 17, 2022 Share Posted March 17, 2022 Hi there, I got this error please help <?php require('mofh/lib.php'); $panel = new Panel("[email protected]", "blablabloblo"); $client = new Client($panel, 'blaa_blabloblo'); echo $client->status; ?> i got "Fatal error: Uncaught Exception: Error. User is not found. in /../mofh/lib.php:137 Stack trace: #0 /../cc.php(4): Client->__construct(Object(Panel), 'blaa_blabloblo') #1 {main} thrown in /../mofh/lib.php on line 137" i tried all username but it's same and it's can't get client data but it's can get panel data please Quote Link to comment Share on other sites More sharing options...
Mahtab Hassan Posted March 17, 2022 Share Posted March 17, 2022 3 hours ago, Geenzo said: Hi there, I got this error please help <?php require('mofh/lib.php'); $panel = new Panel("[email protected]", "blablabloblo"); $client = new Client($panel, 'blaa_blabloblo'); echo $client->status; ?> i got "Fatal error: Uncaught Exception: Error. User is not found. in /../mofh/lib.php:137 Stack trace: #0 /../cc.php(4): Client->__construct(Object(Panel), 'blaa_blabloblo') #1 {main} thrown in /../mofh/lib.php on line 137" i tried all username but it's same and it's can't get client data but it's can get panel data please Can you send me the script? So i can check Quote Link to comment Share on other sites More sharing options...
Geenzo Posted March 17, 2022 Share Posted March 17, 2022 1 hour ago, Shen Wei said: Can you send me the script? So i can check https://github.com/ewallz/mofh-client Quote Link to comment Share on other sites More sharing options...
Mahtab Hassan Posted March 17, 2022 Share Posted March 17, 2022 3 hours ago, Geenzo said: https://github.com/ewallz/mofh-client Ok Quote Link to comment Share on other sites More sharing options...
Mahtab Hassan Posted March 18, 2022 Share Posted March 18, 2022 4 hours ago, BastelPichi2 said: This project is dead, like the creator. (They prolly arent dead but not anymore active) Is that so Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.