GVKun编程网logo

使用 nodejs 对 Marketing Cloud 的 contact 主数据进行修改操作(nodejs setimmediate)

3

本文将带您了解关于使用nodejs对MarketingCloud的contact主数据进行修改操作的新内容,同时我们还将为您解释nodejssetimmediate的相关知识,另外,我们还将为您提供关

本文将带您了解关于使用 nodejs 对 Marketing Cloud 的 contact 主数据进行修改操作的新内容,同时我们还将为您解释nodejs setimmediate的相关知识,另外,我们还将为您提供关于Cloud for Customer 的 contact 主数据 function 字段下拉菜单的绘制原理、Contact Form 7 添加检查验证表单步骤插件 – Contact Form 7 add confirm、Django/Python“django.core.exceptions.ImproperlyConfigured:无法导入‘contact’检查‘...apps.contact.apps.ContactConfig.name’是否正确”、Marketing Cloud API消费entity unsupported format错误消息的处理的实用信息。

本文目录一览:

使用 nodejs 对 Marketing Cloud 的 contact 主数据进行修改操作(nodejs setimmediate)

使用 nodejs 对 Marketing Cloud 的 contact 主数据进行修改操作(nodejs setimmediate)

假设在 Marketing Cloud 有这样一个 contact 主数据:

现在需求是使用编程语言比如 nodejs 修改这个 contact 实例的高亮属性。

代码如下:


var config = require("./mcConfig");
var request = require(''request'');

var url = config.tokenURL;

console.log("user: " + config.user + " password: " + config.password); 
var getTokenOptions = {
        url: url,
        method: "GET",
        json:true,     
        headers: {
            ''Authorization'': ''Basic '' + new Buffer(config.user + ":" + config.password).toString(''base64''),
            "content-type": "application/json",
            "x-csrf-token" :"fetch"
        }
};

function getToken() {
  return new Promise(function(resolve,reject){
      var requestC = request.defaults({jar: true});
      console.log("Step1: get csrf token via url: " + url );

      requestC(getTokenOptions,function(error,response,body){
       var csrfToken = response.headers[''x-csrf-token''];
       if(!csrfToken){
          reject({message:"token fetch error: " + error});
          return;
       }
       console.log("Step1: csrf token got: " + csrfToken);
       resolve(csrfToken);
      }); 
     });
}

function updateContact(token){
	return new Promise(function(resolve, reject){
		var sPostData = "--batch_1f7d-bd35-caed" + "\n" + 
  "Content-Type: multipart/mixed; boundary=changeset_8f9e-9a44-9f9e" + "\n" + 
  "\n" + 
  "--changeset_8f9e-9a44-9f9e" + "\n" + 
  "Content-Type: application/http" + "\n" + 
  "Content-Transfer-Encoding: binary" + "\n" + 
  "\n" + 
  "MERGE Consumers(''02000A21209F1EE99CDF1A1FC9AA8065'')?sap-client=100 HTTP/1.1" + "\n" + 
  "Cache-Control: max-age=360" + "\n" + 
  "sap-contextid-accept: header" + "\n" + 
  "Accept: application/json" + "\n" + 
  "Accept-Language: en" + "\n" + 
  "DataServiceVersion: 2.0" + "\n" + 
  "MaxDataServiceVersion: 2.0" + "\n" + 
  "x-csrf-token: fQ2Pwfmf0K_LVYoKV9QYUw==" + "\n" + 
  "Content-Type: application/json" + "\n" + 
  //"Content-Length: 215" + "\n" + 
  "\n" + 
  "{\"YY1_CustomerType_ENH\":\"Jerry测试1\"}" + "\n" + 
  "--changeset_8f9e-9a44-9f9e--" + "\n" + 
  "\n" + 
  "--batch_1f7d-bd35-caed--";

		var requestC = request.defaults({jar: true});
    var createOptions = {
              url: config.updateContactURL,
              method: "POST",
              json:false,
              headers: {
                  "content-type": "multipart/mixed;boundary=batch_1f7d-bd35-caed",
                  ''x-csrf-token'': token
              },
              body:sPostData
        };
        requestC(createOptions,function(error,response,data){
            if(error){
                reject(error.message);
            }else {
               debugger;
               console.log("Contact updated successfully");
               resolve(data);
            }
        });
	});
}

getToken().then(updateContact).catch((error) =>{
  console.log("error: " + error.message);
});

我在 nodejs 代码里把需要更改的字段值赋为 "Jerry 测试 1”:

执行之后这个属性被成功更新了:

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

Cloud for Customer 的 contact 主数据 function 字段下拉菜单的绘制原理

Cloud for Customer 的 contact 主数据 function 字段下拉菜单的绘制原理

[外链图片转存失败 (img-kY00ou5p-1566695062000)(https://upload-images.jianshu.io/upload_images/2085791-dcc88e58a67cac8c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]
要获取更多 Jerry 的原创文章,请关注公众号 "汪子熙":

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

Contact Form 7 添加检查验证表单步骤插件 – Contact Form 7 add confirm

Contact Form 7 添加检查验证表单步骤插件 – Contact Form 7 add confirm

站长朋友们在使用以后,为了访客能够轻松联系到自己,提高网站的转化率,通常会在网站中加入联系我们的表单,让客户可以方便的在线发邮件给自己预设的邮箱。我们都熟悉,这种表单使用 来做非常方便,但是Contact Form 7插件默认的工作流程是:客户填写咨询信息,点击发送,直接发到站长的邮箱,并没有检查确认的步骤。今天我们就来介绍一款插件 – Contact Form 7 add confirm,这款wordpress插件可以给 Contact Form 7 添加检查验证表单的步骤。

插件安装方法:

1. 在后台的插件里搜索 Contact Form 7 add confirm,在线安装或者,上传到服务器空间。
2. 激活插件。

插件使用方法:
通常提交按钮的代码是:

Django/Python“django.core.exceptions.ImproperlyConfigured:无法导入‘contact’检查‘...apps.contact.apps.ContactConfig.name’是否正确”

Django/Python“django.core.exceptions.ImproperlyConfigured:无法导入‘contact’检查‘...apps.contact.apps.ContactConfig.name’是否正确”

如何解决Django/Python“django.core.exceptions.ImproperlyConfigured:无法导入‘contact’检查‘...apps.contact.apps.ContactConfig.name’是否正确”

希望大家能帮我解决这个问题...

我的工作流程:

  1. |.vscode:
  2. |capstone_project_website:
  3. | -_pycache_:
  4. | -apps:
  5. | -_pycache_
  6. | -accounts:
  7. | -contact: # app that is throwing errors
  8. | -_pycache_:
  9. | -migrations:
  10. | -_init_.py
  11. | -admin.py
  12. | -apps.py
  13. | -forms.py
  14. | -models.py
  15. | -test.py
  16. | -urls.py
  17. | -views.py
  18. | -public:
  19. | -_init_.py
  20. | -templates: # all my .html
  21. | -_init_.py
  22. | -asgi.py
  23. | -settings.py
  24. | -urls.py
  25. | -views.py
  26. | -wsgi.py
  27. |requirements:
  28. |scripts:
  29. |static:
  30. |.gitignore
  31. |.python-version
  32. |db-sqlite3
  33. |docker-compose.yml
  34. |Dockerfile
  35. |Makefile #command I am running
  36. |manage.py
  37. |setup.cfg

我在 capstone_project_website/settings.py 中安装的应用程序:

  1. INSTALLED_APPS = [
  2. "django.contrib.admin","django.contrib.auth","django.contrib.contenttypes","django.contrib.sessions","django.contrib.messages","django.contrib.staticfiles","capstone_project_website.apps.accounts","capstone_project_website.apps.contact",]

我的capstone_project_website/apps/contact/apps.py

  1. from django.apps import AppConfig
  2. class ContactConfig(AppConfig):
  3. name = "contact"

我正在运行的命令在我的 Makefile 中:

  1. compose-start:
  2. docker-compose up --remove-orphans $(options)

当我运行 make compose-start 时,我从我的终端收到此消息:

  1. make compose-start
  2. docker-compose up --remove-orphans
  3. Docker Compose is Now in the Docker CLI,try `docker compose up`
  4. Starting django-website_postgres_1 ... done
  5. Starting django-website_db_migrate_1 ... done
  6. Starting django-website_website_1 ... done
  7. Attaching to django-website_postgres_1,django-website_db_migrate_1,django-website_website_1
  8. db_migrate_1 | Traceback (most recent call last):
  9. db_migrate_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/config.py",line 244,in create
  10. db_migrate_1 | app_module = import_module(app_name)
  11. db_migrate_1 | File "/usr/local/lib/python3.7/importlib/__init__.py",line 127,in import_module
  12. db_migrate_1 | return _bootstrap._gcd_import(name[level:],package,level)
  13. db_migrate_1 | File "<frozen importlib._bootstrap>",line 1006,in _gcd_import
  14. db_migrate_1 | File "<frozen importlib._bootstrap>",line 983,in _find_and_load
  15. db_migrate_1 | File "<frozen importlib._bootstrap>",line 965,in _find_and_load_unlocked
  16. db_migrate_1 | ModuleNotFoundError: No module named ''contact''
  17. db_migrate_1 |
  18. db_migrate_1 | During handling of the above exception,another exception occurred:
  19. db_migrate_1 |
  20. db_migrate_1 | Traceback (most recent call last):
  21. db_migrate_1 | File "manage.py",line 22,in <module>
  22. db_migrate_1 | main()
  23. db_migrate_1 | File "manage.py",line 18,in main
  24. db_migrate_1 | execute_from_command_line(sys.argv)
  25. db_migrate_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py",line 419,in execute_from_command_line
  26. db_migrate_1 | utility.execute()
  27. db_migrate_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py",line 395,in execute
  28. db_migrate_1 | django.setup()
  29. db_migrate_1 | File "/usr/local/lib/python3.7/site-packages/django/__init__.py",line 24,in setup
  30. db_migrate_1 | apps.populate(settings.INSTALLED_APPS)
  31. db_migrate_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py",line 91,in populate
  32. db_migrate_1 | app_config = AppConfig.create(entry)
  33. db_migrate_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/config.py",line 250,in create
  34. db_migrate_1 | app_config_class.__qualname__,db_migrate_1 | django.core.exceptions.ImproperlyConfigured: Cannot import ''contact''. Check that ''capstone_project_website.apps.contact.apps.ContactConfig.name'' is correct.
  35. postgres_1 |
  36. postgres_1 | Postgresql Database directory appears to contain a database; Skipping initialization
  37. postgres_1 |
  38. postgres_1 | 2021-05-02 14:17:44.105 UTC [1] LOG: starting Postgresql 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu,compiled by gcc (Debian 8.3.0-6) 8.3.0,64-bit
  39. postgres_1 | 2021-05-02 14:17:44.106 UTC [1] LOG: listening on IPv4 address "0.0.0.0",port 5432
  40. postgres_1 | 2021-05-02 14:17:44.106 UTC [1] LOG: listening on IPv6 address "::",port 5432
  41. postgres_1 | 2021-05-02 14:17:44.113 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGsql.5432"
  42. postgres_1 | 2021-05-02 14:17:44.121 UTC [28] LOG: database system was shut down at 2021-05-02 14:17:17 UTC
  43. django-website_db_migrate_1 exited with code 1
  44. postgres_1 | 2021-05-02 14:17:44.129 UTC [1] LOG: database system is ready to accept connections
  45. website_1 | Watching for file changes with StatReloader
  46. ^CGracefully stopping... (press Ctrl+C again to force)
  47. Stopping django-website_website_1 ... done
  48. Stopping django-website_postgres_1 ... done

我知道我投入了很多工作流程,但我想知道我是否设置错误。我之前在我的帐户应用程序上尝试 makemigrations 时遇到过这个问题。那个答案似乎奏效了。 答案是将 name 中的 capstone_project_website/apps/accounts/apps.py 更改为

  1. class AccountsConfig(AppConfig):
  2. name = "capstone_project_website.apps.accounts"

在已安装的应用程序中,您可以看到路径是:

  1. "capstone_project_website.apps.accounts",

我已尝试更改...的名称capstone_project_website/apps/contact/apps.py

  1. class ContactConfig(AppConfig):
  2. name = "contact"

...到name=''capstone_project_website.apps.contact'' ...和我安装的应用名称:

  1. INSTALLED_APPS = [
  2. ...
  3. "capstone_project_website.apps.ContactConfig",]

重点是我不确定发生了什么,是目录问题、名称问题还是在make compose-start之前遗漏了某些步骤。如果您能帮我解决这个问题,并解释我做错了什么,我将不胜感激! 谢谢

解决方法

检查您的 Django 版本。如果您将 django 版本更新到 3.2,请尝试切换到最早的版本。

django==3.1.8

,

尝试改变这个:

类 ContactConfig(AppConfig): 姓名 = "联系人"

为此:

类 ContactConfig(AppConfig): name = "apps.contact"

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源创计划”,欢迎正在阅读的你也加入,一起分享。

关于使用 nodejs 对 Marketing Cloud 的 contact 主数据进行修改操作nodejs setimmediate的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于Cloud for Customer 的 contact 主数据 function 字段下拉菜单的绘制原理、Contact Form 7 添加检查验证表单步骤插件 – Contact Form 7 add confirm、Django/Python“django.core.exceptions.ImproperlyConfigured:无法导入‘contact’检查‘...apps.contact.apps.ContactConfig.name’是否正确”、Marketing Cloud API消费entity unsupported format错误消息的处理的相关信息,请在本站寻找。

本文标签:

上一篇php版微信支付api.mch.weixin.qq.com域名解析慢原因与解决方法(微信支付php接口)

下一篇使用postman修改SAP Marketing Cloud contact主数据(postman修改user agent)