how to host customers domain on my server using cpanel api - web-hosting

i am searching a lot here
https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+2
https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+1
but didn't found any correct way. what my requirement is i need to host a domain on my server programmatically, where my clients provide me its domain name (ex: test.com) via a form and when he submit that form, i will set a wordpress site for it using that domain. Currently i setup a subdomain programmatically using cpanel api, what my requirement here is hosting a domain on my server and i have to do this using api.

Above I have suggested the way to create addon domain on a cpanel.
Hereunder is the code to generate new cpanel account on WHM or server
$xmlapi = new \xmlapi($reseller->url);
//checking authentication of the cpanel
$xmlapi->password_auth($reseller->username, $reseller->password);
$xmlapi->set_port(2087);
$xmlapi->set_output('json');
$conf = array("username"=>$username,"password"=>$password,"domain"=>$domain,"pkgname"=>$package,"contactemail"=>$contactemail,"cpmod"=>"x3");
$result = json_decode($xmlapi->createacct($conf));

To connect with cpanel, you will be needed cpanel main domain, cpanel username and cpanel password. You will get connected with cpanel and then can easily create new addon domains. Once you get created addon domain then you can use individual addon domain to manage each domain specifically.
require_once '../components/xmlapi.php';
$xmlapi = new \xmlapi($licence['cpanel_domain']);
//checking authentication of the cpanel
$xmlapi->password_auth($licence['username'],$licence['password']);
$xmlapi->set_port(Yii::$app->params['domainPort']);
$result = $xmlapi->api1_query($licence['password'], 'CustInfo', 'getemail', array());
// Add the "addondomain.com" addon domain.
$api2args = array(
'dir' => 'addondomain/home/dir',
'newdomain' => 'addondomain.com',
'subdomain' => 'subdomain',
);
$add_addon = $xmlapi->api2('AddonDomain', 'addaddondomain', $api2args);

Related

Django sign up with facebook return an error

*as Can't load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and sub-domains of your app to the App Domains field in your app settings.**
im using http://127.0.0.1:8000
so here is how i have set my facebook
domain App domains is 127.0.0.1
Then the url to the sign up page on django is
http://127.0.0.1:8000/user
first you need to install django ssl server then dont access with 127.0.0.1 but use localhost even though it will redirect you to 127.0.0.1 just use localhost:8000
Then on login to admin and on sites rename the domain name to localhost:8000
go to facebook development and add the following
domain name = localhost
go to add platform on bottom of the page and add website then fill this way
http://localhost:8000
HOW TO INSTALL DJANGO SSLSERVER
https://github.com/teddziuba/django-sslserver
HOPE IT WORKS😖😖

Laravel socialite Google login cannot create credentials for localhost server

I'm developing a laravel project with socialite. It is now in my localhost sever. During development, I want to test login/register locally. Hence, my domain is localhost.
I've created a project in google console but can't create credentials for my localhost domain.
https://console.developers.google.com/apis/credentials
When I try to add localhost to Authorized domains Google says Invalid domain: must be a top private domain. Here is a screenshot:
Is is possible to create credentials for localhost?

Laravel mail on shared hosting

I've a form contact on my website and I want the form to be sent via email when submitted.
I've tried it in xampp and it's working fine.
On shared hosting, it does not work.
I'm using my own custom domain smtp.
Someone can explain me why it's not working ?
Your shared hosting probably blocks outgoing SMTP connections. Many hosting providers do that to prevent spam. You can try using a HTTP/WEB API instead of SMTP to send email.
Some email APIs like Flute Mail allow you to set up an HTTP API connection which can immediately forward the request through your "custom domain smtp" server. So you can keep using your custom domain email server, but get an API for it.
Otherwise you'll have to set up a Web API yourself with an open source tool like Postal.
In your laravel .env file if add following parameters mentioned below and create a e-mail on your shared hosting and add username, password and host of your hosting.
MAIL_DRIVER=smtp
MAIL_HOST=shared_host_name
MAIL_PORT=587
MAIL_USERNAME=mail#sharedhost.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
I suppose then it would work fine.

How to generate a www LetsEncrypt certificate using laravel forge?

I provisioned a server using forge and set the domain to blog.example.com. And I generate a LetsEncrypt certificate for that server and set the site to run on http2. It was perfectly fine.
However, I need to make the server accessible via www.blog.example.com now. So I set a CNAME record to route www.blog to blog.example.com. But I got an error This site can’t provide a secure connection when I try to access the site via www.blog.example.com. So I try to generate a new certificate for www.blog.example.com but forge reply First domain does not match root domain on site.
How can I solve the problem?
Thank you.

How to add an addon domain to cpanel with same name but different tld?

I have a cpanel account with option for unlimited add-on domains. I have added a domain, say, example.org. For this, cpanel has also created a sub-domain for main hosting domain example.main-domain.com.
Now I have purchased another domain example.com. When I try to add it through addon domains option, cpanel gives an error that subdomain example.main-domain.com already exists.
Is there a way to add the second domain in this scenario?
The first part of the subdomain is determined by the Subdomain or FTP Username: you set when you add the subdomain.
Cpanel auto-fills this field with the first part of the domain name but you can enter anything you like.
So when you go to add example.com Cpanel will auto-fill the Subdomain or FTP Username: to example and try to create the subdomain example.main-domain.com which already exists from when you added example.org in the same way so it will throw an error like
(XID bqnr82) A DNS entry for the domain “example.main-domain.com” already exists.
Instead when you add example.com enter any unused value into the Subdomain or FTP Username: field, such as exampledotcom and the subdomain cpannel creates will be at
exampledotcom.main-domain.com
This is explained and discussed here
https://forums.cpanel.net/threads/addon-domains-differing-only-in-tld-extension.249141/
You can edit the sub-domain name to example1 while adding the other domain example.com. So, that the next sub-domain will be example1.main-domain.com.
When you create addon domain it also creates subdomain for the addon domain. Now you since create subdomain with name example already so when you attempt to add addon domain with name example.com it could not create subdomain example since it was already added. Just rename already created subdomain and attempt to add the server. It will fix the problem.

Resources