我是 php 函数的新手,所以请耐心等待。这是我的代码:
<?php
require('AuthnetCIM.class.php');
$cim = new AuthnetCIM('26JspTq3A', '6S97jCdwS56P3rGs',AuthnetCIM::USE_DEVELOPMENT_SERVER);
function add_profile()
{
// Create unique fake variables
$email_address = 'user' . time() . '@domain.com';
$description = 'Monthly Membership No. ' . md5(uniqid(rand(), true));
$customer_id = substr(md5(uniqid(rand(), true)), 16, 16);
// Create the profile
$cim->setParameter('email', $email_address);
$cim->setParameter('description', $description);
$cim->setParameter('merchantCustomerId', $customer_id);
$cim->createCustomerProfile();
// Get the profile ID returned from the request
if ($cim->isSuccessful())
{
$profile_id = $cim->getProfileID();
}
// Print the results of the request
echo '<strong>createCustomerProfileRequest Response Summary:</strong> ' .$cim->getResponseSummary() . '';
echo '<strong>Profile ID:</strong> ' . $profile_id . '';
}
add_profile()
?>
我的问题从这一行开始: $cim->setParameter('email', $email_address);
我收到错误:致命错误:调用非对象上的成员函数 setParameter()
我知道这段代码在不在函数中时有效,这只是下一步。我确信我缺少一些简单的东西。任何帮助是极大的赞赏。谢谢你。