|
|
Documentation Wiki > Developer Documentation > Web Service Guide > ExactTarget for Appexchange API Guide > Scenarios
ScenariosFrom $1Table of contents(Click the banner to go to the related Docs.Code.ExactTarget.com page.) Sample Code for ExactTarget for AppExchange API CallsThis section provides sample code related to ExactTarget for AppExchange API. Click the links below to see all applicable API methods, objects, and properties.
Sample Create Call// Action: Create SalesforceSend object
CreateResult[] results = etForAppx.Create(new CreateOptions(), new APIObject[] { sfs }, out requestID, out status);
This code sample represents the create call, and it executes one Salesforce send. Note the following aspects about this call:
Sample Re-subscribe Callprivate void Activate()
{
Console.WriteLine("updating sf subscriber");
int subTypeID = -1;
string status = null;
string rid = null;
PartnerAPI.Subscriber wsdlSub = new PartnerAPI.Subscriber();
//set the 18 digit SF ID
wsdlSub.SubscriberKey = "0037000000UyRdo";
//set the status to active
wsdlSub.Status = SubscriberStatus.Active;
wsdlSub.StatusSpecified = true;
//set the subscriber Type
PartnerAPI.SubscriberTypeDefinition std = new PartnerAPI.SubscriberTypeDefinition();
std.SubscriberType = "salesforcecontact"; //"salesforcelead"
wsdlSub.SubscriberTypeDefinition = std;
wsdlSub.IDSpecified = false;
wsdlSub.Client = new ClientID();
wsdlSub.Client.ID = 3069; //wsdlSub.Client.UserID = objPrincipal.EmployeeID; PartnerAPI.ServiceWse partnerAPI = new PartnerAPI.ServiceWse();
UsernameTokenProvider utp = new UsernameTokenProvider("etsfdev2", "xxxx"); partnerAPI.SetClientCredential<UsernameToken>(utp.GetToken());
Policy policy = new Policy(new UsernameOverTransportAssertion());
partnerAPI.SetPolicy(policy);
partnerAPI.Timeout = -1;
UpdateResult[] results = partnerAPI.Update(new PartnerAPI.UpdateOptions(), new PartnerAPI.APIObject[] { wsdlSub }, out rid, out status);
for (int cntr = 0; cntr < results.Length; cntr++)
{
Console.WriteLine(string.Format("Results for object {0}: Status code: {1}. Message: {2}.", cntr, results[cntr].StatusCode, results[cntr].StatusMessage));
}
Console.ReadLine();
}
Sample Web Service API Call//1. Create email
Email email = new Email();
email.ID = 3079342;
email.IDSpecified = true;
//2. Specify target recipients
Target report = new Target();
report.ObjectID = "00O60000001PWEa";
report.ObjectType = ObjectTypes.Report;
//3. Specify target recipients to exclude from the send
Target reportExclude = new Target();
reportExclude.ObjectID = "00O60000001PWEc";
reportExclude.ObjectType = ObjectTypes.Report;
// 4. Create Salesforce send object
SalesforceSend sfs = new SalesforceSend();
sfs.Email = email;
sfs.Targets = new Target[] { report };
sfs.Exclusions = new Target[] { reportExclude };
sfs.FromName = "Lead/Contact Owner Name"; // Use CRM Record owner from from address and name
sfs.SendDate = DateTime.UtcNow.Add(3); // Use UTC time for Scheduling sends
//5. Use Create call to initiate the send
CreateResult[] results = etForAppx.Create(new CreateOptions(), new APIObject[] { sfs }, out requestID, out status);
// 6. Print out overall results
Console.WriteLine(string.Format("Overall result: {0}. RequestID: {1}. Result Message: {2}", status, requestID, results[0].StatusMessage));
This page was last updated by Ryan Williams on Fri, 06 Jan 2012 21:26:17 GMT. If you require assistance with the ExactTarget application, please contact Global Support. If you wish to send Ryan direct feedback, fill out the form below:
Tags: (Edit tags)
|
Powered by MindTouch 2010 |