2 Replies Latest reply on Jun 20, 2013 2:35 AM by 16532

    scheduleCampaign API

      I'm trying to pass in values for program tokens used in an email with scheduleCampaign.  I'm not receiving any error messages.   The campaign is scheduled and the email goes out the tokens are not the value I sent in with the api request.   Is anyone else using this feature for scheduleCampaign or requestCampaign?
        • Re: scheduleCampaign API
          Yes, we are using this feature with requestCampaign and it works fine.  One thing to note is that the tokens passed in as parameter must have a prefix of "my."   Here's some sample code in PHP -

          // Request campaign with my.Tokens
           
          class LeadKey {
           
              /**
               * @var string
               *     NOTE: keyType should follow the following restrictions
               *     You can have one of the following value
               *     IDNUM
               *     COOKIE
               *     EMAIL
               *     LEADOWNEREMAIL
               *     SFDCACCOUNTID
               *     SFDCCONTACTID
               *     SFDCLEADID
               *     SFDCLEADOWNERID
               *     SFDCOPPTYID
               */
              public $keyType;
           
              /**
               * @var string
               */
              public $keyValue;
           
          }
           
          class ArrayOfLeadKey {
           
              /**
               * @var array[0, unbounded] of (object)LeadKey
               */
              public $leadKey;
           
          }
           
          class Attrib {
           
              /**
               * @param string $name
               * @param string $value
               */
              public function __construct($name = null, $value = null)
              {
                $this->name = $name;
                $this->value = $value;
              }
              
              /**
               * @var string
               */
              public $name;
           
              /**
               * @var string
               */
              public $value;
           
          }
           
          class ArrayOfAttrib {
           
              /**
               * @param array $attrib
               */
              public function __construct($attrib = null)
              {
                $this->attrib = $attrib;
              }
              
              /**
               * @var array[0, unbounded] of (object)Attrib
               */
              public $attrib;
           
          }
           
          class paramsRequestCampaign {
           
              /**
               * @var string
               *     NOTE: source should follow the following restrictions
               *     You can have one of the following value
               *     MKTOWS
               *     SALES
               */
              public $source;
           
              /**
               * @var int
               */
              public $campaignId;
           
              /**
               * @var (object)ArrayOfLeadKey
               */
              public $leadList;
           
              /**
               * @var string
               */
              public $programName;
           
              /**
               * @var string
               */
              public $campaignName;
           
              /**
               * @var (object)ArrayOfAttrib
               */
              public $programTokenList;
           
          }
           
            public function testRequestCampaignOverrideTokens()
            {
                 $key = new LeadKey();
                 $key->keyType = "EMAIL";
                 $key->keyValue = "aahsan99@gmail.com";
                 $key2 = new LeadKey();
                 $key2->keyType = "EMAIL";
                 $key2->keyValue = "agha@marketo.com";
                 $leads = array();
                 $leads[] = $key;
                 $leads[] = $key2;
                 $leadList = new ArrayOfLeadKey();
                 $leadList->leadKey = $leads;
           
                 $tokens = array();
                 // The {{ }} are optional, but 'my.' is required
                 $tokens[] = new Attrib("{{my.Offer Start}}","1/1/2013");
                 $tokens[] = new Attrib("{{my.Offer End}}","10/1/2013");
                 $tokenList = new ArrayOfAttrib($tokens);
           
                 $params = new paramsRequestCampaign();
                 $params->source = "MKTOWS";
                 $params->campaignName = "My Cool Campaign";
                 $params->programName = "Winter 2013";
                 $params->programTokenList = $tokenList;
                 $params->leadList = $leadList;
           
                 $authHdr = apiClientUtil::getAuthenticationHeader(self::$wsUser, null, null, $params);
            
                 $client = $this->getSoapClient();
                 $success = $client->__soapCall('requestCampaign', array($params), null, $authHdr);
            
                 $this->assertNotNull($success, 'Response is null');
                 $this->assertNotNull($success->result, 'Result in response is null');
                 $this->assertTrue($success->result->success, 'API failure reported');
            }
          • Re: scheduleCampaign API
            Hi All

            I'm using PHP and the request is going fine, but I'm not able to send "programTokenList" with the request.

            I have created 2 tokens, which I can not pass:

            {{company.Company Name:default=ABC}}
            {{company.Company Notes:default=These are company notes}}

            Can you please tell me how to pass programTokenList parameter. Also if there is a problem with the below mentioned code.
                      
                      
                      Here is the code


                      <?php
                      //Using Marketo API
                        require_once('marketo.php');

                      //Create Object
                        $marketo_client = new Marketo('credant1_317901074F67792C3E8DC1', '802726366303923744FF6677779922DE33EE9DCE7007', '654-UUH-339.mktoapi.com/');

                      //API Calls, uncomment to see result
                        //$value = $marketo_client->get_lead_by('idnum', '255');
                        //$value = $marketo_client->get_lead_by('email', 'akauth@cisco.com');

                      //  $leads = array('email' => 'himanshu.khatri@mentisconsultinginc.com');

                      //Himanshu
                      //  $leads = array('IDNUM'=>'1223299');
                      //Viresh
                        $leads = array('IDNUM'=>'1223701');

                      //tokens
                        $tokens = array();
                        $tokens[] = array('{{my.company.Company Name}}'=>'NocorP');
                        $tokens[] = array('{{my.company.Company Notes}}'=>'Here are the notes');

                      //Campaign ID which will run
                        $value = $marketo_client->add_to_campaign('1665A1',$leads);

                      //Display array of fetched result.
                        echo "<pre>";
                        print_r($value);



            Thanks