I'm working on a WHM API and want to find the cPanel username by passing the domain name.
NOTE: I've the credentials of WHM.
There is no such documentation exists here https://documentation.cpanel.net/pages/viewpage.action?pageId=1507786
So, is there a way to achieve do so?
Update:
Now, I'm using xmlapi.php and here is what I tried so far.
require_once(base_path() . "/vendor/cpanel_api/xmlapi.php");
$ip = env('SERVER_IP', "127.0.0.1"); //your server's IP
$xmlapi = new \xmlapi($ip);
$xmlapi->password_auth(env('CPANEL_USER', "root"),env('CPANEL_PASSWORD', "")); //the server login info for the user you want to create the emails under
$xmlapi->set_output('json');
$xmlapi->set_debug(1);
$params = array('domain'=>$domain, 'searchtype'=>'domain'); //quota is in MB
$res = json_decode($xmlapi->api2_query('root', "listaccts", "", $params), true);
print_r($res);
in $xmlapi->api2_query method, there are 4 arguments
cPanel Username
WHM Module Name
Function under the Given Module in step 2
parameters, that'll be passed to the function in step 3
I have to find out the cPanel Username, so, I wrote the 'root' for now. but no success
Please give a try with cPanel API.
Here are the some useful docs of API.
https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+2
https://documentation.cpanel.net/display/SDK/Guide+to+WHM+API+1
Related
I'm trying to connect my website (in Developer Mode, so Sandbox True, non https) to Intuit from the Consolibyte "docs/partner_platform/example_app_ipp_v3/index.php" file, but I keep getting the following error:
Uh oh, there’s a connection problem. Sorry, but the app didn’t
connect. Please try again later, or contact customer support for help.
View error details (for Developers) The redirect_uri query parameter
value is invalid. Make sure it is listed in the Redirect URIs section
on your app's keys tab and matches it exactly. Click here to learn
more about the redirect_uri query parameter.
I've set the Redirect Uri in my intuit developer account for this app to the same Return URL in the Consolibyte config.php (docs/partner_platform/example_app_ipp_v3/success.php), but it still isn't working.
Am I doing something wrong? I followed everything in the quick start guide correctly.
config.php code:
$oauth_client_id = '***';
$oauth_client_secret = '***';
// If you're using DEVELOPMENT TOKENS, you MUST USE SANDBOX MODE!!! If you're in PRODUCTION, then DO NOT use sandbox.
$sandbox = true; // When you're using development tokens
//$sandbox = false; // When you're using production tokens
// This is the URL of your OAuth auth handler page
$quickbooks_oauth_url = 'http://www.***.com/quickbooks/docs/partner_platform/example_app_ipp_v3/oauth.php';
// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$quickbooks_success_url = 'http://www.***.com/quickbooks/docs/partner_platform/example_app_ipp_v3/success.php';
// This is the menu URL script
$quickbooks_menu_url = 'http://www.***.com/quickbooks/docs/partner_platform/example_app_ipp_v3/menu.php';
// This is a database connection string that will be used to store the OAuth credentials
// $dsn = 'pgsql://username:password#hostname/database';
// $dsn = 'mysql://username:password#hostname/database';
$dsn = 'mysqli://***_intuit:***#localhost/***_quickbooks';
// You should set this to an encryption key specific to your app
$encryption_key = '***';
// Scope required
$scope = 'com.intuit.quickbooks.accounting ';
// The tenant that user is accessing within your own app
$the_tenant = 12345;
Your redirect URL doesn't match.
In Intuit's control panel it ends with success.php.
In your configuration, it ends with oauth.php.
The two URLs have to match exactly.
Also, make sure you're using the latest code from https://github.com/consolibyte/quickbooks-php - if you're using the latest code, you should have a config_oauthv2.php file and not just config.php.
Hello i want to create ftp for particular users.. I have searched on google but nothing found. So i have decided to put question on stackoverflow. I have tried below code but not working at all :-
$cpaneluser = "xxxxx"; // i have entered my cpanel user
$cpanelpass = "xxx"; //pwd
$domain = "testing.domain.com"; //here i have entered the domain
$fuser = "testing#domain.com";
$fpass = "mypwd";
$homedir = "/direcctorypath";
$url = "http://$cpaneluser:$cpanelpass#$domain:2082/json-api/cpanel?";
$url .= "cpanel_jsonapi_version=2&cpanel_jsonapi_module=Ftp&cpanel_jsonapi_func=addftp&";
$url .= "user=$fuser&pass=$fpass&homedir=$homedir"a=0";
var_dump($url);
$result = file_get_contents($url);
var_dump($http_response_header);
if ($result === FALSE)
die("ERROR: FTP Account not created. Please make sure you passed correct parameters.");
echo $result;
SEE OUTPUT
Every time its output coming FTP Account not created. Please make sure you passed correct parameters..
But i have entered the correct details. i Don't know why its not working.
So later on i have decide lets do with exec command but that also not working
Ref Url :- Creating FTP user accounts using FTP on server
exec("adduser -c 'testing#domain.com' -m testing123"); // this is not working at all
After checking above url i have added the username and password of ftp account. But i have one doubt where i passed the cpanel useranme and password in exec function. Can anyone tell me how to create ftp account of a user. Thanks in advance
I am using the quickbooks-php from GitHub. The version is quickbooks-php-master\docs\partner_platform\quickbooks-php-master\docs\partner_platform\example_app_ipp_v3.
I used this version 3 or 4 years ago and it work OK. Recently I wanted to try it again for a project. Since the last time I used it they only used OAUTH1 now they are using OAUTH2 for login and I'm not able to connect to my Sandbox account. I get a general error when the php coded tries to return the company name.
My question is do I need to make changes to the quickbooks-php-master\docs\partner_platform\example_app_ipp_v3 version in order to get it working again. I have the Development Keys (Client ID and Client Secret) from the developers site.
The config.php file is where you place these keys:
$token = 'xxx';
oauth_consumer_key = 'xxx';
`$oauth_consumer_secret = 'xxx';
The names of these keys have changed so it is a bit confusion as to whether these can work this way.
So the main question is does example_app_ipp_v3 work with OAUTH2 and if so can you direct me to the changes I need to make.
Any help on this would be great. If this version doesn't work with OAUTH2 I just need to know if that is the case so I can try something else.
OAuth2.0 support is being rolled out now. Check out the migration guide here:
https://github.com/consolibyte/quickbooks-php#oauth-10-to-oauth-20-migration
And the most recent updates. More updates to come. The configuration code changes a bit to accommodate the new OAuth 2.0 requirements:
$oauth_client_id = 'Q0ql65UCww8oAoiXfNdVyZ5WHoZ0kJ43XqstMhxGtM2UuA5WKu';
$oauth_client_secret = 'S60VXMXFygEOcb08DleS8iePUFyH81i4FhVrKaAB';
$sandbox = true; // When you're using development tokens
// This is the URL of your OAuth auth handler page
$quickbooks_oauth_url = 'http://sandbox.test/quickbooks-php/docs/partner_platform/example_app_ipp_v3/oauth.php';
// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$quickbooks_success_url = 'http://sandbox.test/quickbooks-php/docs/partner_platform/example_app_ipp_v3/success.php';
// This is the menu URL script
$quickbooks_menu_url = 'http://sandbox.test/quickbooks-php/docs/partner_platform/example_app_ipp_v3/menu.php';
// This is a database connection string that will be used to store the OAuth credentials
$dsn = 'mysqli://dev:password#localhost/quickbooks';
// You should set this to an encryption key specific to your app
$encryption_key = 'bcde1234';
// Scope required
$scope = 'com.intuit.quickbooks.accounting ';
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere(
QuickBooks_IPP_IntuitAnywhere::OAUTH_V2,
$sandbox,
$scope,
$dsn,
$encryption_key,
$oauth_client_id,
$oauth_client_secret,
$quickbooks_oauth_url,
$quickbooks_success_url);
I am trying to return data from CPanel's APIv2, in the case below.. I am trying to curl out the last 15 minute of logs from a client account, where the variables CUSTOMER_USER_NAME is a customer user name and DOMAIN_NAME_FOO.COM is the customer's domain name.
curl --insecure https://MASTERUSER:masterhash#MASTERIP_foo:2087/json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_user=CUSTOMER_USER_NAME_FOO&cpanel_jsonapi_module=Stats&cpanel_jsonapi_func=lastapachehits&domain=DOMAIN_NAME_FOO.COM
When I run the Curl the JSON that comes back is:
{"cpanelresult":{"data":{"reason":"User parameter is invalid or was not supplied","result":"0"},"type":"text","error":"User parameter is invalid or was not supplied"}
Both that user and domain are CPanel accounts and in PHP this works -> file_get_contents on the admin interface however I am coding this daemon in another language and even shell STDOUT would suffice here.
Does anyone have any idea how I would accomplish this? I figured I would capture stdout from curl for my Ruby daemon framework and go from there if there isn't a adequate ruby like way of doing this.
Thanks in advance.
Heres the answer I was looking for that I solved myself in case anyone else has had trouble using ruby to manipulate the CPanel V2 API
require 'httparty'
$user = 'v****l' #master user account username
$apihash = '86W***********V' #api hash
$url = '10.**4.1**.**9' #sample ip address of server
class Cpanel
include HTTParty
base_uri "http://#{$url}:2086/json-api"
def initialize(u, p)
#auth = {:username => u, :password => p}
end
# mod = cPanel module
# function = function, really!
# args = function's arguments
def api(mod, func, args={})
query = { :cpanel_jsonapi_user => #auth[:username],
:cpanel_jsonapi_module => mod,
:cpanel_jsonapi_func => func,
:cpanel_jsonapi_apiversion => 2,
}
options = {}
query.merge!(args)
options.merge!({ :query => query, :basic_auth => #auth })
result = self.class.post('/cpanel', options)
#result = result.to_hash['cpanelresult']['data']
return result
end
end
cpanel = Cpanel.new($user, $apihash)
puts cpanel.api('Stats', 'lastapachehits', { :domain => 'hu***********.org' }) #where hu**********.org is the account to acquire logs from
This can be repurposed for any of CPanelV2's APIs, just remember that 2087 is SSL and 2086 is encrypted.
How to upload videos using youtube api from localhost web application in codeigniter or php?
I followed the steps in youtube library as follows:
api key : 'my developer key'
consumer key : 'anonymous'
consumer secret : 'anonymous'
I am using the functions as follows and my site url is : http://localhost/ci-youtube/example/request_youtube
//CALL THIS METHOD FIRST BY GOING TO
//www.your_url.com/index.php/request_youtube
public function request_youtube()
{
$params['key'] = 'anonymous';
$params['secret'] = 'anonymous';
$params['algorithm'] = 'HMAC-SHA1';
$this->load->library('google_oauth', $params);
$data = $this->google_oauth->get_request_token(site_url('example/access_youtube'));
print_r($data);
$this->session->set_userdata('token_secret', $data['token_secret']);
redirect($data['redirect']);
//$this->load->view('welcome_message');
}
//This method will be redirected to automatically
//once the user approves access of your application
public function access_youtube()
{
$params['key'] = 'anonymous';
$params['secret'] = 'anonymous';
$params['algorithm'] = 'HMAC-SHA1';
$this->load->library('google_oauth', $params);
$oauth = $this->google_oauth->get_access_token(false, $this->session->userdata('token_secret'));
$this->session->set_userdata('oauth_token', $oauth['oauth_token']);
$this->session->set_userdata('oauth_token_secret', $oauth['oauth_token_secret']);
}
But it shows the error : 'Invalid Token'
Any idea ?
Thanks in advance for quick reply.
I think you still haven't got an API key from YouTube yet. Is that so?
I haven't published this yet but I'm about to release a PHP based Youtube autouploader, that allows you to run uploads from a NAS box, spare PC etc.
https://github.com/Danack/Youtube-Autouploader
It has a complete example for how to upload videos to Youtube in there, in particular the function "uploadVideo($filename, $videoInfo)"
https://github.com/Danack/Youtube-Autouploader/blob/master/youtubeCurl.php
First make sure you are using the correct consumer key and consumer secret.
Second if you run into problems with either the Google_oauth library or the Youtube library make sure you set the DEBUG constant in those libraries to true. Doing that will dump a lot more logging information in to the PHP error log which should help you diagnose the problem.
Timestamp is too far from current time:
It seems like your server time is not correctly set. Please correct your server time, you may want to restart your web server after fixing the time. - Change Server time. Try restart Webserver first. If not work, restart your Computer ==> it work!.