GVKun编程网logo

使用Java代码在SAP Marketing Cloud上创建Contact数据(java调用sap接口)

1

在这篇文章中,我们将带领您了解使用Java代码在SAPMarketingCloud上创建Contact数据的全貌,包括java调用sap接口的相关情况。同时,我们还将为您介绍有关BoostYourSt

在这篇文章中,我们将带领您了解使用Java代码在SAP Marketing Cloud上创建Contact数据的全貌,包括java调用sap接口的相关情况。同时,我们还将为您介绍有关Boost Your Strategy With The Content Marketing Tools、Marketing Cloud API消费entity unsupported format错误消息的处理、Marketing Cloud contact主数据的csv导入、Marketing Cloud contact的API介绍的知识,以帮助您更好地理解这个主题。

本文目录一览:

使用Java代码在SAP Marketing Cloud上创建Contact数据(java调用sap接口)

使用Java代码在SAP Marketing Cloud上创建Contact数据(java调用sap接口)

源代码:

package partner1;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import sun.misc.BASE64Encoder;

public class SimpleContactCreator {

	private ConfigUtil mConfigUtil = new ConfigUtil();
	
	HttpClient m_httpClient;

	public SimpleContactCreator(){
		enableHeaderWireAndContextLogging();
	}
	
	private void enableHeaderWireAndContextLogging(){
		System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
		System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
		System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", "debug");
		System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
		System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "debug");
	}
	private String getBasicAuth(){
		final String text = mConfigUtil.getConfig("user") + ":" + mConfigUtil.getConfig("password");		
		BASE64Encoder encoder = new BASE64Encoder();
		String credentials = "basic " + encoder.encode(text.getBytes());
		return credentials;
	}
	
	private HttpClient getHttpClient() {
		if (this.m_httpClient == null) {
			this.m_httpClient = HttpClientBuilder.create().build();
		}
		return this.m_httpClient;
	}
	
	private String getCSRFToken(){
		String url = mConfigUtil.getConfig("tokenurl");
		System.out.println("fetch CSRF token via url: " + url);
		final HttpGet get = new HttpGet(url);
		get.setHeader("Authorization", getBasicAuth());
		get.setHeader("Cache-Control", "no-cache");
		get.setHeader("content-type", "application/json");
		get.setHeader("Accept", "application/json");
		get.setHeader("x-csrf-token", "fetch");

		HttpResponse response;
		String token = null;
		try {
			response = getHttpClient().execute(get);
			StatusLine statusLine = response.getStatusLine();
			int code = statusLine.getStatusCode();
			System.out.println("Status code: " + code);
			System.out.println("reason: " + statusLine.getReasonPhrase());
			
			token = response.getFirstHeader("x-csrf-token").getValue();
			System.out.println("token: " + token);
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException | UnsupportedOperationException e) {
			e.printStackTrace();
		}
		return token;
	}
	
	public void run(String body){
		String token = getCSRFToken();
		createContact(token, body);
	}
	private void createContact(String token, String body){
		final HttpPost post = new HttpPost(
			URI.create(mConfigUtil.getConfig("contactcreateurl")));
		post.setHeader("Authorization", getBasicAuth());
		post.setHeader("Content-Type", "application/json");
		post.setHeader("X-CSRF-Token", token);
		HttpEntity entity = null;
		try {
			entity = new StringEntity(body);
		} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
		}
		post.setEntity(entity);

		HttpResponse response = null;
		try {
			response = getHttpClient().execute(post);
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		System.out.println("Response statusCode for Batch => "
			+ response.getStatusLine().getStatusCode());
	}

	public static void main(String[] args) {
		SimpleContactCreator tool = new SimpleContactCreator();
		String body = "{\"IsConsumer\":true," + 
                      "\"Filter\":{\"MarketingArea\":\"CXXGLOBAL\"}," + 
                      "\"__metadata\":{\"type\":\"CUAN_CONTACT_SRV.InteractionContact\"}," + 
                      "\"FirstName\":\"SAP Diablo\",\"LastName\":\"SAP Wang\",\"Country\":\"CN\"," + 
                      "\"EMailAddress\":\"seya@sap.com\",\"YY1_WECHATID_MPS\":\"i042416\"," + 
                      "\"YY1_FACEID_MPS\":\"d042416\"}";
		tool.run(body);
	}
}

package partner1;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigUtil {
	
	Properties prop; 
	
	public ConfigUtil(){
		InputStream input = null;
		prop = new Properties();
		
		String propFileName = "config.properties";

		input = getClass().getClassLoader().getResourceAsStream(propFileName);

		if (input != null) {
				try {
					prop.load(input);
				} catch (IOException e) {
					e.printStackTrace();
				}
		}
	}
	
	public String getConfig(String name){
		return prop.getProperty(name);
	}
	
	public static void main(String[] argv){
		ConfigUtil tool = new ConfigUtil();
		System.out.println("User: " + tool.getConfig("user"));
	}
}

config.properties文件放在resources文件夹下:

user=mkt
password=MY

tokenurl=https://jerry.hybris.com/sap/opu/odata/sap/CUAN_COMMON_SRV/?sap-client=100
# not batch
contactcreateurl=https://jerry.hybris.com/sap/opu/odata/sap/CUAN_CONTACT_SRV/InteractionContacts?sap-client=100

本文分享 CSDN - 汪子熙。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

Boost Your Strategy With The Content Marketing Tools

Boost Your Strategy With The Content Marketing Tools

Boost Your Strategy With The Content Marketing Tools

In today’s digital landscape, content marketing tools have emerged as a crucial component of any successful online business. Delivering valuable and engaging content to your target audience drives traffic, builds brand awareness, and increases conversions. However, managing and optimizing content marketing efforts can only be challenging with the right tools.

Content Management Systems (CMS)

A reliable CMS forms the foundation of your content marketing efforts. With a friendly interface, efficient organization, and powerful publishing capabilities: a CMS empowers you to create, edit and manage your content seamlessly.

WordPress, Drupal, and Joomla are popular CMS platforms that offer a wide range of features, including content scheduling, SEO optimization, and friendly plugins.

Keyword Research Tools

Keywords play a key role in content marketing, enabling you to understand what your target audience is searching for and optimizing your content accordingly. Tools like Google Keyword Planner, SEMrush, and Ahrefs provide valuable insights into keyword volume, competition, and related terms.

These tools help you uncover untapped opportunities, optimize your content for search engines and enhance your organic visibility.

Content Ideation and Research Tools

Generating fresh, captivating content ideas can be a daunting task. Content ideation tools such as BuzzSumo, Portent’s Content Idea Generator, and HubSpot’s Blog Ideas Generator can inspire your creativity by suggesting popular topics, trending themes, and related content in your industry.

These content marketing tools also help you conduct comprehensive research, analyze competitor content and uncover data-backed insights for creating compelling and unique content.

Content Creation and Collaboration Tools

Once you have your content ideas, it’s essential to create high-quality and visually appealing assets. Tools like Canva, Adobe Creative Cloud, and Piktochart provide intuitive interfaces and a wide range of templates, graphics, and design elements to help you produce stunning visuals and infographics.

Additionally, collaboration tools like Google Docs, Trello, and Asana streamline the content creation process by facilitating real-time collaboration, task assignment, and version control among team members.

https://vucac.com/

Social Media Management Tools

Promoting your content across social media channels is crucial for maximizing its reach and engagement. Social media management tools like Hootsuite, Buffer, and Sprout Social allow you to schedule posts, monitor conversations, analyze performance, and manage multiple accounts from a centralized dashboard.

These tools simplify social media marketing, enabling you to distribute and amplify your content across various platforms effectively.

Analytics and Performance Tracking Tools

Measuring the success of your content marketing efforts is essential for making data-driven decisions and optimizing your strategy. Google Analytics, Moz, and Content Marketing Institute’s Content Strategy Tool provide in-depth analytics and reporting features, enabling you to track website traffic, user behavior, conversion rates, and engagement metrics.

By analyzing these insights, you can refine your content strategy, identify areas for improvement and drive continuous growth.

Conclusion

A potent strategy for attracting, enticing, and converting your target audience is content marketing. However, it is essential to use the correct content marketing tools that streamline your workflow, improve your content creation process, and offer actionable insights if you want to get the best outcomes. You may maximize the effectiveness of your content marketing initiatives and promote long-term business growth by adding these tools to your strategy.

also see https://www.vucac.com/solutions/content-marketing-tools

出处:公号「程序员泥瓦匠」 博客: https://bysocket.com/

内容涵盖 Java 后端技术、Spring Boot、Spring Cloud、微服务架构、运维开发、系统监控等相关的研究与知识分享。

Marketing Cloud API消费entity unsupported format错误消息的处理

Marketing Cloud API消费entity unsupported format错误消息的处理

在消费SAP Marketing Cloud API时,遇到如下错误:

解决方案是在发起http请求的头部添加content-type字段,类型为multipart/mixed:

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

本文同步分享在 博客“汪子熙”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

Marketing Cloud contact主数据的csv导入

Marketing Cloud contact主数据的csv导入

使用这个mock数据生成器网站https://www.mockaroo.com/b6790790,创建一个基于Marketing Cloud contact schema的csv文件。

如果偷懒的话,每个contact字段的值都可以选择随机生成。点Download Data下载到本地。

打开csv文件之后,还可以用文本编辑器对值进行微调。

进入Marketing Cloud,点Import进行导入:

在business administration这个catalog里的import monitor对导入过程进行监控:

导入成功:

导入的数据可以在Marketing Cloud里使用了:

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

Marketing Cloud contact的API介绍

Marketing Cloud contact的API介绍

下图的contact列表是Marketing Cloud调用后台odata服务后显示的:

URL:https://jerry.gcdemo.hybris.com/sap/opu/odata/sap/CUAN_CONTACT_SRV/$batch?sap-client=100

http请求的正文:
–batch_c914-a60c-1877
Content-Type: application/http
Content-Transfer-Encoding: binary

GET InteractionContacts?sap-client=100&KaTeX parse error: Expected ''EOF'', got ''&'' at position 7: skip=0&̲top=45& s e l e c t = I m a g e U R L select=ImageURL%2cName%2cContactLevelName%2cCountryName%2cCity%2cEMailAddress%2cPhoneNumber%2cMobilePhoneNumber%2cCorporateAccountName%2cInteractionContactUUID%2cRelationship%2cType& select=ImageURLinlinecount=allpages HTTP/1.1
sap-cancel-on-close: true
Cache-Control: max-age=360
sap-contextid-accept: header
Accept: application/json
Accept-Language: en
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0

–batch_c914-a60c-1877–

http响应:

{“d”:{"__count":“1218374”,“results”:[{"__metadata":{“id”:“https://diablo.gcdemo.hybris.com/sap/opu/odata/sap/CUAN_CONTACT_SRV/InteractionContacts(‘00163E1B0A701EE6939977B1F8726D4C’)”,“uri”:“https://diablo.gcdemo.hybris.com/sap/opu/odata/sap/CUAN_CONTACT_SRV/InteractionContacts(‘00163E1B0A701EE6939977B1F8726D4C’)”,“type”:“CUAN_CONTACT_SRV.InteractionContact”},“InteractionContactUUID”:“00163E1B0A701EE6939977B1F8726D4C”,“City”:“Newman”,“ContactLevelName”:“Self-Identified”,“CorporateAccountName”:"",“CountryName”:“USA”,“EMailAddress”:“0200205812_agatha.steward-90@outlook.com”,“ImageURL”:"",“MobilePhoneNumber”:"",“Name”:“Agatha Steward”,“PhoneNumber”:"",“Relationship”:1,“Type”:“01”},{"__metadata":{“id”:“https://diablo.gcdemo.hybris.com/sap/opu/odata/sap/CUAN_CONTACT_SRV/InteractionContacts(‘00163E1B0A701ED6939FBB838E1E803A’)”,“uri”:“https://diablo.gcdemo.hybris.com/sap/opu/odata/sap/CUAN_CONTACT_SRV/InteractionContacts(‘00163E1B0A701ED6939FBB838E1E803A’)”,“type”:“CUAN_CONTACT_SRV.InteractionContact”},“InteractionContactUUID”:“00163E1B0A701ED6939FBB838E1E803A”,“City”:"",“ContactLevelName”:“Self-Identified”,“CorporateAccountName”:"",“CountryName”:“USA”,“EMailAddress”:“antonioifernandez@einrot.com”,“ImageURL”:"",“MobilePhoneNumber”:"",“Name”:“Antonio Fernandez”,“PhoneNumber”:"",“Relationship”:0,“Type”:“01”},{"__metadata":要获取更多Jerry的原创文章,请关注公众号"汪子熙":

本文同步分享在 博客“汪子熙”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

今天关于使用Java代码在SAP Marketing Cloud上创建Contact数据java调用sap接口的分享就到这里,希望大家有所收获,若想了解更多关于Boost Your Strategy With The Content Marketing Tools、Marketing Cloud API消费entity unsupported format错误消息的处理、Marketing Cloud contact主数据的csv导入、Marketing Cloud contact的API介绍等相关知识,可以在本站进行查询。

本文标签: