dsvyc66464 2009-08-04 18:52
浏览 60
已采纳

如何连接到Campaign Monitor API?

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.

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.

  • 写回答

1条回答 默认 最新

  • down_load1117 2009-08-05 05:47
    关注

    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.

    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');
    

    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'];
    

    Since you're only interested in adding a deleting users from a mailing list, I think the only two API calls you need to worry about are subscriberAdd() and subscriberUnsubscribe():

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

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。