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.

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

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测