0

我正在开发通过 Infusionsoft API 和 XMLRPC 从我们的网站发送电子邮件的代码。

这是我的代码:

$email = $user_rec['email'];
    $contactID=$user_rec['client_infusionid'];      
    echo $contactID;

    $Subject = 'Your reset password request at GIC Deal Finders';

    $From = $this->GetFromAddress();

    $link = 'http://dashboard.gicdealfinders.info/resetpwd.php?email='.
            urlencode($email).'&code='.
            urlencode($this->GetResetPasswordCode($email));

    $htmlBody ='Hello '.$user_rec["name"].'<br/><br/>'.
    'There was a request to reset your password at GIC Deal Finders<br/>'.
    'Please click the link below to complete the request: <br/><a href="'.$link.'">'.$link.'</a><br/><br/>'.
     '<br/>'.
    'Regards,<br/>'.
    'Toyin Dawodu, MBA<br/>'.
    'Founder and Chief Relationship Officer';

    $clients = new xmlrpc_client("https://ze214.infusionsoft.com/api/xmlrpc");
    $clients->return_type = "phpvals";
    $clients->setSSLVerifyPeer(FALSE);
    ###Build a Key-Value Array to store a contact###
    $emailI = array(
    'contactList' => $contactID,
    'fromAddress' => $From,
    'toAddress' => $email,
    'ccAddresses' => 'admin@gicdealfinders.info',
    'bccAddresses' =>'abhilashrajr.s@gmail.com',
    'contentType' => 'HTML',
    'subject' => $Subject,
    'htmlBody' => $htmlBody,
    'textBody' => 'test');
    //$check=$myApp->sendEmail($clist,"Test@test.com","~Contact.Email~", "","","Text","Test Subject","","This is the body");

    ###Set up the call###
        $calls = new xmlrpcmsg("APIEmailService.sendEmail", array(
        php_xmlrpc_encode($this->infusion_api),         #The encrypted API key
        php_xmlrpc_encode($emailI)      #The contact array

        ));

        ###Send the call###
        $results = $clients->send($calls);
        //$conID = $results->value();
        /*###Check the returned value to see if it was successful and set it to a variable/display the results###*/
        if(!$results->faultCode()) {
            return true;
            } else {
                print $results->faultCode() . "<BR>";
                print $results->faultString() . "<BR>";
            return false;
            }

捕获的错误显示:

-1
No method matching arguments: java.lang.String, java.util.HashMap

任何人都可以检查我的代码并向我展示修复它的方法吗?

4

1 回答 1

0

正如返回的错误所说,错误的参数被发送到 Infusionsoft API。

Infusionsoft API 文档中提供了可接受的参数列表。

首先,您需要将您的API 密钥添加为$emailI数组中的第一个值。

此外,Infusionsoft API 期望第二个参数是联系人 ID 列表,这意味着第二个参数$contactID必须从 php 端作为数组发送。

以下代码显示了修复:

$emailI = array(
    'yourApiKey',
    array($contactID),
    $From,
    $email,
    'admin@gicdealfinders.info',
    'abhilashrajr.s@gmail.com',
    'HTML',
    $Subject,
    $htmlBody,
    'test'
);
$calls = new xmlrpcmsg(
    "APIEmailService.sendEmail",
     array_map('php_xmlrpc_encode', $emailI)
);

另请注意,如果您的代码中只有一个或两个 Infusionsoft API 调用,建议使用API Helper Libraries。如果当前的官方帮助程序库不适合您,您 还可以在github.com上找到 Infusionsoft API 的另一个包装器。

于 2016-06-18T13:27:32.290 回答