对于那些熟悉使用Chargify和PHP的人,我试图执行应该是一个简单的请求。我正在使用Chargify API创建一个新用户。我的这部分代码正在运行。请求正在发送,Chargify正在记录新客户。我希望能够获取刚刚创建的客户的ID。这就是我正在使用的,它正在抛出错误。
码
// Create a ChargifyProduct object in test mode.
$customer->email = $_POST['email'];
$customer->first_name = $_POST['first_name'];
$customer->last_name = $_POST['last_name'];
$new_customer = $customer->create();
//Grab customer ID
$customer_x = $new_customer->getByID();
错误
Fatal error: Uncaught exception 'ChargifyConnectionException' with message 'An error occurred while connecting to Chargify: Couldn't resolve host '.chargify.com' (6)' in /home/assets/lib/ChargifyConnector.php:99 Stack trace: #0 /home/\assets/lib/ChargifyConnector.php(146): ChargifyConnector->sendRequest('/customers.xml', 'XML', 'POST', '<?xml version="...') #1 /home/assets/lib/ChargifyConnector.php(157): ChargifyConnector->requestCreateCustomer('<?xml version="...') #2 /home/assets/lib/ChargifyCustomer.php(43): ChargifyConnector->createCustomer(Object(ChargifyCustomer)) #3 /home/andfun4/photoappoint.com/register/index.php(20): ChargifyCustomer->create() #4 {main} thrown in /home/assets/lib/ChargifyConnector.php on line 99
对此的任何见解将不胜感激。
感谢
答案 0 :(得分:2)
显示的错误并非来自显示的代码!
看看这些代码中的代码,它们会导致错误:
$new_customer = $customer->create();
//Grab customer ID
$customer_x = $new_customer->getByID();
正如我读到的那样,在这些行中,与数据库建立了连接,并且无法解析第一个参数(主机名),因为它不是exixst。