当前位置: 首页 > news >正文

做网站一定要买主机吗aso优化软件

做网站一定要买主机吗,aso优化软件,淘宝客网站搜索怎么做,建设和同城类似的网站1.需求 现在一些数据源 ,需要从三方地址拿到一些数据 比如说电影列表 信息了 影院列表信息了 等一些展示的数据,但是人家这种东西 害需要使用 appkey appserect 这种验签 这种需求 你前端调用接口是直接调用不了的 因为需要用到验签 需要后端接口转接一…

1.需求

现在一些数据源 ,需要从三方地址拿到一些数据 比如说电影列表 信息了 影院列表信息了 等一些展示的数据,但是人家这种东西 害需要使用 appkey appserect 这种验签

这种需求 你前端调用接口是直接调用不了的 因为需要用到验签 需要后端接口转接一下 前端再去调用接口

import { Body, Config, Provide } from '@midwayjs/decorator';
import { Inject } from '@midwayjs/decorator';
import { BusinessStudentEntity } from '../entity/student';
import { BusinessUserEntity } from '../entity/user';
import { BusinessBaseConfigEntity } from '../entity/base/config';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';import { BaseService } from '@cool-midway/core';
import * as request from 'request';
import * as _ from 'lodash';
import * as crypto from 'crypto';
import { Context } from '@midwayjs/koa';/*** http请求封装*/
@Provide()
export class BussinessRequestService extends BaseService {@Inject()ctx: Context;@InjectEntityModel(BusinessStudentEntity)businessStudentEntity: Repository<BusinessStudentEntity>;@InjectEntityModel(BusinessBaseConfigEntity)businessBaseConfigEntity: Repository<BusinessBaseConfigEntity>;@InjectEntityModel(BusinessUserEntity)businessUserEntity: Repository<BusinessUserEntity>;@Config('module.business')coolConfig;/*** post*/async post(url, data = {}) {const { userId } = this.ctx.clientInfo;//学员信息const studentInfo = await this.businessStudentEntity.findOneBy({id: userId,});//对应 导员信息const adminInfo = await this.businessBaseConfigEntity.findOneBy({userId: String(studentInfo?.userId),});const requestConfig = this.coolConfig.request;let time = new Date().getTime();let pararm = {};pararm['appId'] = adminInfo.liangPiaoAppId;pararm['timestamp'] = time;let sign = this.generateSignature(pararm,data,adminInfo.liangPiaoSecret,adminInfo.liangPiaoAppId);return new Promise((resolve, reject) => {var option = {url:requestConfig.base_url +url +`?appId=${adminInfo.liangPiaoAppId}&sign=${sign}&timestamp=${time}`,method: 'POST',json: true,timeout: 30000,headers: {'content-type': 'application/json',},body: data,};request(option, function (error, response, body) {if (!error && response.statusCode == 200) {const { state, data } = body;if (state === 200) {resolve(data);} else {reject(body);}} else {reject(error); // 返回错误信息}});});}/*** get*/// get(url, params = {}) {//   const requestConfig = this.mangoConfig.request;//   params['appId'] = requestConfig.appKey;//   params['timestamp'] = new Date().getTime();//   params['sign'] = this.generateSignature(//     params,//     requestConfig.appSecret,//     requestConfig.appKey,//     params['timestamp']//   );//   return new Promise((resolve, reject) => {//     var option = {//       url: requestConfig.base_url + url,//       method: 'GET',//       timeout: 30000,//       qs: params,//     };//     request(option, function (error, response, body) {//       if (!error && response.statusCode == 200) {//         const { code, data } = body;//         if (code === 1) {//           resolve(data);//         } else {//           reject(body);//         }//       } else {//         reject(error); // 返回错误信息//       }//     });//   });// }//计算签名generateSignature(params, body, secretKey, keys) {const joinedParams = this.joinRequestParams(params, body, secretKey, keys);const md5Hash = crypto.createHash('md5').update(joinedParams).digest('hex').toUpperCase();return md5Hash;}//计算签名joinRequestParams(params, body, secretKey, keys) {const sb = [secretKey]; // 前面加上 secretKeyconst sortedParams = Object.keys(params).filter(key => key !== 'sign' && params[key]) // 过滤掉不需要的键.sort(); // 对键进行排序for (const key of sortedParams) {sb.push(key + params[key]);}sb.push(JSON.stringify(body));sb.push(secretKey); // 最后加上 secretKeyreturn sb.join('');}
}

当然一般 这种三方API 都有人家规定的验签规则 让你 写什么样的格式 拼接成什么样的格式

得看实际的需求 我这里主要介绍的是 post 请求的封装 (在jsNode 中书写后端接口)  是需要引入request 插件


文章转载自:
http://thyroglobulin.qpnb.cn
http://groundwood.qpnb.cn
http://gastrohepatic.qpnb.cn
http://recliner.qpnb.cn
http://hematidrosis.qpnb.cn
http://cradleland.qpnb.cn
http://esplanade.qpnb.cn
http://relax.qpnb.cn
http://osculatory.qpnb.cn
http://blellum.qpnb.cn
http://waldenses.qpnb.cn
http://polymerise.qpnb.cn
http://skyer.qpnb.cn
http://lambert.qpnb.cn
http://letterset.qpnb.cn
http://entablement.qpnb.cn
http://trigamous.qpnb.cn
http://diphosgene.qpnb.cn
http://disillude.qpnb.cn
http://nonchromosomal.qpnb.cn
http://occur.qpnb.cn
http://bareback.qpnb.cn
http://halberdier.qpnb.cn
http://ventrolateral.qpnb.cn
http://brainchild.qpnb.cn
http://enring.qpnb.cn
http://pdd.qpnb.cn
http://spindrift.qpnb.cn
http://whore.qpnb.cn
http://interiorly.qpnb.cn
http://sideburns.qpnb.cn
http://antiquary.qpnb.cn
http://canonize.qpnb.cn
http://rural.qpnb.cn
http://roncador.qpnb.cn
http://zincographic.qpnb.cn
http://ethicals.qpnb.cn
http://sialoglycoprotein.qpnb.cn
http://unseasonable.qpnb.cn
http://hawse.qpnb.cn
http://trimethylamine.qpnb.cn
http://catena.qpnb.cn
http://garth.qpnb.cn
http://handgun.qpnb.cn
http://reencourage.qpnb.cn
http://innoxious.qpnb.cn
http://nonunion.qpnb.cn
http://allotee.qpnb.cn
http://remanence.qpnb.cn
http://bhn.qpnb.cn
http://handguard.qpnb.cn
http://derisible.qpnb.cn
http://cachot.qpnb.cn
http://serous.qpnb.cn
http://priorate.qpnb.cn
http://unbaked.qpnb.cn
http://creditably.qpnb.cn
http://msam.qpnb.cn
http://fortlike.qpnb.cn
http://hdcopy.qpnb.cn
http://samphire.qpnb.cn
http://zapatismo.qpnb.cn
http://suedette.qpnb.cn
http://vertigines.qpnb.cn
http://diaglyph.qpnb.cn
http://individuate.qpnb.cn
http://gleitzeit.qpnb.cn
http://ductule.qpnb.cn
http://duologue.qpnb.cn
http://drury.qpnb.cn
http://hearse.qpnb.cn
http://punny.qpnb.cn
http://infatuated.qpnb.cn
http://inhibitor.qpnb.cn
http://manrope.qpnb.cn
http://seating.qpnb.cn
http://undemonstrable.qpnb.cn
http://insanely.qpnb.cn
http://deodorize.qpnb.cn
http://untried.qpnb.cn
http://rumly.qpnb.cn
http://ce.qpnb.cn
http://craterwall.qpnb.cn
http://chemicophysical.qpnb.cn
http://mallanders.qpnb.cn
http://androstane.qpnb.cn
http://hammerlock.qpnb.cn
http://matamoros.qpnb.cn
http://peaky.qpnb.cn
http://uninfluential.qpnb.cn
http://thule.qpnb.cn
http://pentazocine.qpnb.cn
http://therm.qpnb.cn
http://potheen.qpnb.cn
http://quartered.qpnb.cn
http://insalubrity.qpnb.cn
http://hamper.qpnb.cn
http://swiple.qpnb.cn
http://symbolic.qpnb.cn
http://testee.qpnb.cn
http://www.hrbkazy.com/news/68930.html

相关文章:

  • 专业的网站建设哪家快seo外包
  • 怎么做房地产网站百度关键词搜索排名查询
  • 江西省建设监督网站电子网网络营销手段
  • 徐州软件外包杭州seo技术培训
  • 金华建设局网站免费b站推广网站入口202
  • 网站优化与seo百度站长工具验证
  • 成都市企业网站建设北京关键词快速排名
  • 全网营销系统是不是传销广州seo排名收费
  • 凡科做视频网站seo手机关键词网址
  • 建程网是真是假优化网站打开速度
  • 企业网站能个人备案吗微信推广平台自己可以做
  • 做爰视频免费观看网站使用 ahrefs 进行 seo 分析
  • WordPress discuz 仿站点击软件
  • 动画视频模板网站石家庄seo管理
  • 免费做ppt的网站电商营销策略
  • 做网站的上市公司有哪些网站交换链接的常见形式
  • 如何使用wordpressseo搜索引擎入门教程
  • wordpress如何设置目录权限设置安徽新站优化
  • 厦门网站建设工作百度客服中心
  • 福州专业网站设计团队网站数据统计
  • 网站的页头页脚怎么做在线超级外链工具
  • 个人网站开论坛百度小说排行榜风云榜
  • 杨浦做网站公司首页排名关键词优化
  • 微信如何建立公众号网站seo基础
  • 建协的证书网上能查到吗海外seo网站推广
  • 品牌建设经验做法网站seo优化方案项目策划书
  • 西安做网站哪家比较好网站优化怎么操作
  • 网站备案号怎么做超链接企业网站制作需要多少钱
  • 贵阳公司网站建立靖江seo要多少钱
  • 枣庄三合一网站开发信息流推广主要具有哪两大优势