Authentication issues - php

I have been using the API with no problems for a long time. All of a sudden I'm getting this error:
PHP Fatal error: Uncaught PodioError
Request URL:
Stack Trace:
#0 /srv/users/serverpilot/apps/dellentconsulting/public/vendor/podio/lib/Podio.php(93): Podio::request('POST', '/oauth/token', Array, Array)
#1 /srv/users/serverpilot/apps/dellentconsulting/public/pages/careers.php(97): Podio::authenticate('app', Array)
#2 /srv/users/serverpilot/apps/dellentconsulting/public/index.php(58): include('/srv/users/serv...')
#3 {main}
thrown in /srv/users/serverpilot/apps/dellentconsulting/public/vendor/podio/lib/Podio.php on line 283
I didn't make any changes in my code, or applications key.
The error occurs in this code fragment:
<?php
require_once 'vendor/podio/PodioAPI.php';
require_once 'vendor/podio/utils/config-careers.php';
Podio::setup(CLIENT_ID, CLIENT_SECRET);
if (!Podio::is_authenticated()) {
Podio::authenticate('app', array('app_id' => APP_ID, 'app_token' => APP_TOKEN));
}
I already made a restart to the server.

Bit of a wild guess, but could it be a network issue, did you check that you can reach Podio API from the server all the time?

Related

PHP Cpanel_PublicAPI Create Account passing incorrect variables

I am sorry if this request is in the wrong area.
I am learning to use PHP and the CPanel API. I've got the following code and it's giving me a stack error because I am missing something seemingly simple
$domain = array('username' => 'bobbie', 'domain' => 'bobbie.com', 'pass' => 'bobbie123');
$acct = $cp->whm_api('createacct', $domain);
echo "WHM Create: {$acct->createacct}\n";
I know I'm connecting to WHM properly because my code before this outputs the version of WHM correctly. The above code is giving me an error stating that createacct needs to be passed an array as the first parameter:
WHM Version: 11.54.0.21
PHP Fatal error: Uncaught exception 'Exception' with message 'createacct requires that first parameter passed to it is an array' in /root/whmrm/Cpanel/Service/XmlapiClientClass.php:146
Stack trace:
#0 [internal function]: Cpanel_Service_XmlapiClientClass->createacct('bobbie', 'bobbie.com', 'bobbie123')
#1 /root/whmrm/Cpanel/Service/WHM.php(195): call_user_func_array(Array, Array)
#2 [internal function]: Cpanel_Service_WHM->__call('createacct', Array)
#3 [internal function]: Cpanel_Service_WHM->createacct('bobbie', 'bobbie.com', 'bobbie123')
#4 /root/whmrm/Cpanel/PublicAPI.php(525): call_user_func_array(Array, Array)
#5 /root/whmrm/create_sites_on_server.php(68): Cpanel_PublicAPI->__call('whm_api', Array)
#6 /root/whmrm/create_sites_on_server.php(68): Cpanel_PublicAPI->whm_api('createacct', Array)
#7 {main}
thrown in /root/whmrm/Cpanel/Service/XmlapiClientClass.php on line 146
Line 3 of the output is showing that I'm not sending the data properly. Any help would be appreciated. I've googled and most of the results give me information about the xml_api and how to use that. Thanks for your assistance.
Looking at the source for the PublicAPI class, it appears that if an array is given as the parameters, it only calls the resulting function passing the first element from the array (source).
I was able to create an account using this code:
$cp = Cpanel_PublicAPI::getInstance($config);
$whm = Cpanel_PublicAPI::factory('whm');
$domain = array(
'domain' => 'mydomain.com',
'username' => 'drewt2',
'password' => 'myp4ssw0rd!'
);
$response = $whm->createacct($domain);
You can see the functions and there parameters here: Cpanel_Service_XmlapiClientClass.
Unfortunately, the code hasn't been updated in 5 years, and the examples aren't that helpful so you'll likely have to look through the code to figure out most of what you'll want to do.

Error handlers in neo4j-php-client

I downloaded and installed neo4j-php-client and neo4j 2.3.2. Actually all works fine, but I just wondering why there is no error handlers in this php client? For example if there is an error in cypher query, no error has throwing to be easy to catch it. I searching through the network, but I can't found a solution.
Do anybody have an idea how to turn on error handlers?
Thanks in advance.
I'm the maintainer of neo4j-php-client.
When you send a query to Neo4j, it is actually sent via Guzzle.
Of course there is a try/catch block for handling exceptions, which is located here :
https://github.com/graphaware/neo4j-php-client/blob/master/src/HttpClient/GuzzleHttpClient.php#L76
If there is an error in your cypher query, an exception will be thrown of course, the exception is of type Neo4jException (https://github.com/graphaware/neo4j-php-client/blob/master/src/Exception/Neo4jException.php)
Here is a simple code with a cypher syntax error and you can see an exception is thrown :
<?php
require_once __DIR__ .'/vendor/autoload.php';
use Neoxygen\NeoClient\ClientBuilder;
$client = ClientBuilder::create()
->addConnection('default', 'http', 'localhost', 7474)
->setAutoFormatResponse(true)
->build();
$query = 'MATCH (n) RETURN x';
$result = $client->sendCypherQuery($query)->getResult();
-
ikwattro#graphaware ~/d/g/p/neo4j-php-client> php test.php
PHP Fatal error: Uncaught Neoxygen\NeoClient\Exception\Neo4jException: Neo4j Exception with code "Neo.ClientError.Statement.InvalidSyntax" and message "Variable `x` not defined (line 1, column 18 (offset: 17))
"MATCH (n) RETURN x"
^" in /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php:117
Stack trace:
#0 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php(104): Neoxygen\NeoClient\Extension\AbstractExtension->checkResponseErrors(Array)
#1 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/NeoClientCoreExtension.php(98): Neoxygen\NeoClient\Extension\AbstractExtension->handleHttpResponse(Object(Neoxygen\NeoClient\Request\Response))
#2 [internal function]: Neoxygen\NeoClient\Extension\NeoClientCoreExtension->sendCypherQuery('MATCH (n) RETUR...')
#3 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/ExtensionManager.php(53): call_user_func_array(Array, Array)
#4 /Users/ikwattro/dev/graphaware/php/neo4j-php-cli in /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php on line 117
Fatal error: Uncaught Neoxygen\NeoClient\Exception\Neo4jException: Neo4j Exception with code "Neo.ClientError.Statement.InvalidSyntax" and message "Variable `x` not defined (line 1, column 18 (offset: 17))
"MATCH (n) RETURN x"
^" in /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php:117
Stack trace:
#0 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php(104): Neoxygen\NeoClient\Extension\AbstractExtension->checkResponseErrors(Array)
#1 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/NeoClientCoreExtension.php(98): Neoxygen\NeoClient\Extension\AbstractExtension->handleHttpResponse(Object(Neoxygen\NeoClient\Request\Response))
#2 [internal function]: Neoxygen\NeoClient\Extension\NeoClientCoreExtension->sendCypherQuery('MATCH (n) RETUR...')
#3 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/ExtensionManager.php(53): call_user_func_array(Array, Array)
#4 /Users/ikwattro/dev/graphaware/php/neo4j-php-cli in /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php on line 117
Thanks for the answer. The problem is seems on my end, I figured out after few tests - Error hanldering overwrites by the php framework.

Create subdomain by cpanel api

I register on youhosting.com and use domain that registered on godaddy.com. I want to create new subdomain by programming. I have already see the tutorial on cPanel Documentation 1 and Doc 2
After I implement it, it show errors :
Fatal error: Uncaught exception 'Exception' with message 'curl_exec threw error "couldn't connect to host" for https://bodoamat.com:2087/xml-api/listips?' in /home/u937182156/public_html/xmlapi.php:748 Stack trace: #0 /home/u937182156/public_html/xmlapi.php(666): xmlapi->curl_query('https://bodoama...', '', 'Authorization: ...') #1 /home/u937182156/public_html/xmlapi.php(2055): xmlapi->xmlapi_query('listips') #2 /home/u937182156/public_html/listips_example.php(44): xmlapi->listips() #3 {main} thrown in /home/u937182156/public_html/xmlapi.php on line 748
include 'xmlapi.php';
$ip='127.0.0.1';
$root_pass='mypassword';
$xmlapi = new xmlapi($host);
$xmlapi->set_port(2082);
$xmlapi->password_auth($my_user, $my_pass);
$xmlapi->set_debug(1);
print $xmlapi->api1_query($account, "Subdomain", "addsubdomain", array('user123', 'bodoamat.com'));
Any one may help me?
Thanks before
$xmlapi->api1_query($cpanelusr, 'SubDomain', 'addsubdomain', array('user123','bodoamat.com',0,0, '/public_html/directory_name'))

PHP SOAP Function name must be a string?

Sorry about posting the whole error. Basically I have two functions that are running on the soap server and work great. I've added a third function 'getk' that does nothing more complicated that the others. Accepts two parameters and returns an array. However when calling this function client side I get the following error.
Fatal error: Uncaught SoapFault exception:
[SOAP-ENV:Server] Function name must be a string in /home/od2u/public_html/wp-content/plugins/link-monitor/link-monitor.php:33
Stack trace: #0 [internal function]: SoapClient->__call('getk', Array)
#1 /home/od2u/public_html/wp-content/plugins/link-monitor/link-monitor.php(33): SoapClient->getk('3', 'wpmu1')
#2 /home/od2u/public_html/wp-content/themes/twentyten/header.php(18): wsfKeywords('3', 'wpmu1')
#3 /home/od2u/public_html/wp-includes/theme.php(1086): require_once('/home/od2u/publ...')
#4 /home/od2u/public_html/wp-includes/theme.php(1062): load_template('/home/od2u/publ...', true)
#5 /home/od2u/public_html/wp-includes/general-template.php(34): locate_template(Array, true)
#6 /home/od2u/public_html/wp-content/themes/twentyten/index.php(16): get_header()
#7 /home/od2u/public_html/wp-includes/template-loader.php(43): include('/home/od2u/publ...')
#8 /home/od2u/public_html/wp-blog-header.php(16): require_once('/home/od2u/publ...')
#9 /home/od2u/public_html/index.php(17): require( in /home/od2u/public_html/wp-content/plugins/link-monitor/link-monitor.php on line 33
I have looked everywhere for advice on how to sort this. The functions does exist, it isn't anything silly like a dollar sign or using the wrong type of parenthesis.
I have also cleared and disabled caching of the WSDL server and client side.
Client side call:
$c->getk($site, $server);
$c is the soap client and getk is the function name.
Function server side:
function getk($website, $server)
{
$ret_array('blah', 'blah2', 'blah3');
return $ret_array;
}
And this is added to the soap server using:
$server->addFunction(array("getk", "getLinks", "getDirectLinks"));
Hope you guys can help :)
I think, the problem is in
$ret_array('blah', 'blah2', 'blah3');
Interpreter try to resolve this as function call, but can't find variable $ret_array
I had the same error and after some deeper examination, the problem appeared to be on the side of the Soap-server.
The called routine (in this example the getk() function) produced a fatal error which resulted in the Soap-server not giving a proper response that could be interpreted by the Soap-client.
If someone has the same error, please check the errorlogs of the Soap-server if possible. You will propably find that the called function produces a fatal error and is "thus" not returning any xml.

XMLRPC calling SOAP need to return response instead of crashing/dying

So I have a XMLRPC developed in Zend PHP which calls a SOAP request to start another process (SOAP is not my script but the XMLRPC is).
During the SOAP request if the host is not found, this sometimes crashes my XMLRPC call.
How can I return the XMLRPC request with a response instead of an error? Does the logic look ok? I know all the functionality works and I have gotten the response I desire (sometimes) but I need to make sure the script doesn't crash. Any thoughts? tips?
Here is what I have
try {
$soap_call = new ReportSoapClient();
$soap_call->RunReport();
} catch(Exception $e) {
// Set the Error Alert Email Message
$this->setErrorAlertMessage($this->getErrorAlertMessage()."ERROR: SOAP Exception: ".$e->getMessage());
// Send the Email
$this->sendErrorAlertEmail();
// This set the XMLRPC Response
$this->setXMLRPCResponse('Code: '.$e->getCode().' Message: '.$e->getMessage());
// This is a logger
$this->debug('Code: '.$e->getCode().' Message: '.$e->getMessage());
// Return the XMLRPC Response
return $this->getXMLRPCResponse();
}
Here is the email I get:
ERROR: SOAP Exception: Could not connect to host
Here is the error I get when crashing (happens only sometimes, why???):
Fatal error: Uncaught exception 'Zend_Http_Client_Adapter_Exception' with message 'Read timed out after 10 seconds' in /usr/share/php/libzend-framework-php/Zend/Http/Client/Adapter/Socket.php:512
Stack trace:
#0 /usr/share/php/libzend-framework-php/Zend/Http/Client/Adapter/Socket.php(330): Zend_Http_Client_Adapter_Socket->_checkSocketReadTimeout()
#1 /usr/share/php/libzend-framework-php/Zend/Http/Client.php(989): Zend_Http_Client_Adapter_Socket->read()
#2 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client.php(280): Zend_Http_Client->request('POST')
#3 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client.php(361): Zend_XmlRpc_Client->doRequest(Object(Zend_XmlRpc_Request))
#4 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client/ServerProxy.php(93): Zend_XmlRpc_Client->call('system.multical...', Array)
#5 [internal function]: Zend_XmlRpc_Client_ServerProxy->__call('multicall', Array)
#6 /path/to/xmlrpc.client.php(70): Zend_XmlRpc_Client_ServerProxy->multicall(Array)
#7 {main}
thrown in /usr/share/php/libzend-framework-php/Zend/Http/Client/Adapter/Socket.php on line 512
I increased the timeout to 30 seconds (<-- Link: if you need to see how) and then I sometimes get this: (again why???):
Fatal error: Uncaught exception 'Zend_Http_Client_Adapter_Exception' with message 'Read timed out after 30 seconds' in /usr/share/php/libzend-framework-php/Zend/Http/Client/Adapter/Socket.php:512
Stack trace:
#0 /usr/share/php/libzend-framework-php/Zend/Http/Client/Adapter/Socket.php(330): Zend_Http_Client_Adapter_Socket->_checkSocketReadTimeout()
#1 /usr/share/php/libzend-framework-php/Zend/Http/Client.php(989): Zend_Http_Client_Adapter_Socket->read()
#2 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client.php(280): Zend_Http_Client->request('POST')
#3 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client.php(361): Zend_XmlRpc_Client->doRequest(Object(Zend_XmlRpc_Request))
#4 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client/ServerProxy.php(93): Zend_XmlRpc_Client->call('system.multical...', Array)
#5 [internal function]: Zend_XmlRpc_Client_ServerProxy->__call('multicall', Array)
#6 /path/to/xmlrpc.client.php(23): Zend_XmlRpc_Client_ServerProxy->multicall(Array)
#7 in /usr/share/php/libzend-framework-php/Zend/Http/Client/Adapter/Socket.php on line 512
Here is what comes back sometimes (this is the desired response):
Code: 0 Message: Could not connect to host
it was the SOAP process erroring out and wasn't throwing the error properly. ugh

Categories