我如何连接到的Campaign Monitor API? [英] How do I connect to the Campaign Monitor API?

查看:131
本文介绍了我如何连接到的Campaign Monitor API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几分的PHP编码语言的知识,我想连接的Campaign Monitor API(的链接)与我的网站,这样,当用户输入一些内容在我的网站的形式,将其添加到数据库中的Campaign Monitor的服务器上。我发现PHP code例如zip文件,但它包含了像30个文件,我不知道从哪里开始。

I have somewhat of a knowledge of the PHP coding language and I would like to connect the Campaign Monitor API(Link) with my website, so that when the user enters something into the form on my site it will add it to the database on the Campaign Monitor servers. I found the PHP code example zip file, but it contains like 30 files, and I have no idea where to begin.

有谁知道一个教程任何地方,说明如何连接到API中一步一步地吗?自己的code文件包括很多code,我可能不需要简单地连接到数据库,并添加和删除用户,因为我只是想给用户从邮件添加和删除用户的权力清单。

Does anyone know of a tutorial anywhere that explains how to connect to the API in a step-by-step manner? The code files by themselves include to much code that I may not need for simply connecting to the database and adding and deleting users, since I only want to give the user the power to add and delete users from the Mailing List.

推荐答案

这实际上看起来pretty简单。为了使用API​​,您只需包括() CMBase.php 文件,该文件是在ZIP文件中。

This actually looks pretty straightforward. In order to use the API, you simply need to include() the CMBase.php file that is in that zip file.

一旦你包含该文件,您可以创建一个 CampaignMonitor 对象,并用它来访问API函数。我把这个例子出在那里code文件之一:

Once you've included that file, you can create a CampaignMonitor object, and use it to access the API functions. I took this example out of one of the code files in there:

require_once('CMBase.php');

$api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$client_id = null;
$campaign_id = null;
$list_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id );

//This is the actual call to the method, passing email address, name.
$result = $cm->subscriberAdd('joe@notarealdomain.com', 'Joe Smith');

您可以检查这样的调用(再次从他们的code例子所)的结果是:

You can check the result of the call like this (again taken from their code examples):

if($result['Result']['Code'] == 0)
	echo 'Success';
else
	echo 'Error : ' . $result['Result']['Message'];

既然你只能在从邮件列表添加删除用户感兴趣的话,我觉得只有两种API调用,你需要担心的是 subscriberAdd() subscriberUnsubscribe()

$result = $cm->subscriberAdd('joe@notarealdomain.com', 'Joe Smith');
$result = $cm->subscriberUnsubscribe('joe@notarealdomain.com');

希望有所帮助。包含在该下载示例文件是一个单独的API方法调用的所有奇异的例子,这些文件在一个体面的方式命名,所以你应该能够看到的任何文件进行相应的API方法的一个例子。

Hope that helps. The example files that are included in that download are all singular examples of an individual API method call, and the files are named in a decent manner, so you should be able to look at any file for an example of the corresponding API method.

这篇关于我如何连接到的Campaign Monitor API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆