0

我正在尝试从我在 infusion soft 中的 java 应用程序创建联系人,但未能得到响应。有时我收到连接超时错误,有时收到错误 596。

我的示例代码在同伴之下:

public static void addContact() {
try {
//Sets up the java client, including the api url
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setConnectionTimeout(60 * 1000);
config.setReplyTimeout(60 * 1000);
config.setServerURL(new URL(\"https://api.infusionsoft.com/\"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);

//The secure encryption key
String key = \"sdfsdfsdfsdfs34534534534534\";

/**
* ***********************************************
* *
* ADD CONTACT TO DATABASE *
* ***********************************************
*/
List parameters = new ArrayList();
Map contactData = new HashMap();
contactData.put(\"FirstName\", \"Java John\");
contactData.put(\"LastName\", \"Doe\");
contactData.put(\"Email\", \"john@doe.com\");

parameters.add(key); //The secure key
//parameters.add(\"Contact\"); //The table we will be adding to
parameters.add(contactData); //The data to be added

//Make the call
Integer contactId = (Integer) client.execute(\"ContactService.add\", parameters);
System.out.println(\"Contact added was \" + contactId);
} catch (MalformedURLException ex) {
System.out.println(ex);
} catch (XmlRpcException ex) {
System.out.println(ex);
}
}

如何在 Java 中使用 XMLRPC 服务在输液软件中创建联系人?我可以有示例代码吗?

4

1 回答 1

0

这是在输液软件中创建联系人的完整代码。

密钥:密钥参数是输液软件在创建账户时提供的秘钥

URL:“ https://myApp.infusionsoft.com:443/api/xmlrpc ”,需要在“myApp”的地方写上你的应用程序的名称。

public static void addContact() {
        try {
            //Sets up the java client, including the api url
            XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
            config.setServerURL(new URL("https://myApp.infusionsoft.com:443/api/xmlrpc"));
            XmlRpcClient client = new XmlRpcClient();
            client.setConfig(config);

            //The secure encryption key
            String key = "34534k34h5k34hj34k5hhk";

            /**
             * ***********************************************
             *                                               *
             * ADD CONTACT TO DATABASE *
             * ***********************************************
             */
            List parameters = new ArrayList();
            Map contactData = new HashMap();
            contactData.put("FirstName", "Java John");
            contactData.put("LastName", "Doe");
            contactData.put("Email", "john@doe.com");

            parameters.add(key); //The secure key
            //parameters.add("Contact"); //The table we will be adding to
            parameters.add(contactData); //The data to be added

            //Make the call
            Integer contactId = (Integer) client.execute("ContactService.add", parameters);
            System.out.println("Contact added was " + contactId);
        } catch (MalformedURLException ex) {
            System.out.println(ex);
        } catch (XmlRpcException ex) {
            System.out.println(ex);
        }
    }

花了 3 天我能够得到解决方案后,它是完整的工作代码。

于 2016-05-10T06:07:35.093 回答