如何使用XMLAPI-PHP创建一个插件域? [英] How to create an addon domain using xmlapi-php?

查看:256
本文介绍了如何使用XMLAPI-PHP创建一个插件域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个使用XMLAPI的PHP的插件域。我有一个共享的托管帐户。

I am trying to create an addon domain using xmlapi-php. I have a shared hosting account.

本示例code是 github上

<?php

    include '../xmlapi.php';    
    $ip = getenv('REMOTE_HOST');
    $root_pass = getenv('REMOTE_PASSWORD');

    $domain = "somedns.com";

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);
    $xmlapi->set_http_client('curl');
    $xmlapi->set_port(2086);
    $xmlapi->set_debug(1);

    print $xmlapi->adddns($domain,$ip);            
?>

我无法得到这个code携手共创一个插件域。如何能做到?

I am having trouble getting this code to work to create an addon domain. How can it be done?

推荐答案

好吧,我想通了,尽我的能力,这里是所有失魂解掉有:

Well I've figured it out to the best of my ability and here is the solution for all the lost souls out there:

验证

您需要进行身份验证和XML API封装运行以下code。至少一次:

You need run the following code at least once for authentication and xml api wrapper:

// AUTHENTICATION -------------------------

  include("xmlapi.php");    

  $host = "Host ip address or Site.com";
  $my_user = "Your cPanel user ID";
  $my_pass = "Your cPanel password";

  $xmlapi = new xmlapi($host);
  $xmlapi->set_port(2083);
  $xmlapi->password_auth($my_user, $my_pass);
  $xmlapi->set_output('json');
  $xmlapi->set_debug(1);

现在你可以开始使用在xmlapi.php提供的功能,但你不局限于他们。

Now you can start using the functions provided in the xmlapi.php but you are not limited to them.

电子邮件创建示例

// Calling on the function "addpop" "email_user@email_domain" ------------------------- 

  $email_user = "apitest";
  $email_password = "adfm90f";
  $email_domain = "somesite.com";
  $email_query = '10';
  $email_quota = '600';

  //$result will be set equal to the JSON output returned by the call
  //api1_query is the function
  //in the array is where you pass the required parameters

  $result = $xmlapi->api1_query($my_user, "Email", "addpop", 
  array($email_user, $email_password, $email_quota, $email_domain));

显示结果

 $result = json_decode($result, true); //Decoding the JSON results to PHP
 print_r($result); //Printing the array onto the page

 //example of displaying a particular array key, in this example its "result"

 echo $result['data']['result'];

这篇关于如何使用XMLAPI-PHP创建一个插件域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆