没有匹配参数的方法:java.lang.String,java.util.HashMap XMLRPC infusionsoft

时间:2016-06-17 09:21:35

标签: php xml-rpc infusionsoft

我正在开发代码,通过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

任何人都可以检查我的代码并告诉我一种解决方法吗?

1 个答案:

答案 0 :(得分:0)

如返回的错误所示,错误的参数将发送到Infusionsoft API。

Infusionsoft API documentation中提供了可接受参数列表。

首先,您需要将 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的另一个包装器。