微信公众号迁移之OpenID转换-基于C++,curl,rapidjson

博客简单记录了代码片段,无特别内容,参考的是微信接口API。

简单记录一下代码片段,没什么特别内容。参考微信接口API

///	@brief 获取新旧openid对照
///	@param old_app_id 旧服务号appid
///	@param new_app_id 新服务号appid
///	@param old_openid_lst 旧openid列表
///	@return 成功数
int CWeChatHttp::get_new_openids_from_old_openids(const std::string& old_app_id, const std::string& access_token, std::list<std::string>& old_openid_lst)
{
   
   
	int iSucCount = 0;
	// 每次转换100个,超过微信不支持
	if (old_openid_lst.size() > 100)
	{
   
   
		return -1;
	}

	// 构造post的Json串
	Document doc;
	doc.SetObject();

	Document::AllocatorType& allocate = doc.GetAllocator();
	Value from_appid(StringRef(old_app_id.c_str()));
	doc.AddMember("from_appid", from_appid, allocate);

	// 构造json内容数组
	rapidjson::Value openid_list(rapidjson::kArrayType);
	std::list<std::string>::iterator it = old_openid_lst.begin();
	for (; it != old_openid_lst.end(); ++it)
		openid_list.PushBack(StringRef((*it).c_str()), allocate);

	doc.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值