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

PHP 复制商品扩展实操:轻松切换一号通、99api ,实现商品复制功能

目前已有一号通、99api复制商品扩展

复制商品扩展入口

namespace crmeb\services\copyproduct;use crmeb\basic\BaseManager;
use crmeb\services\AccessTokenServeService;
use think\facade\Config;
use think\Container;/*** Class Product* @package crmeb\services\copyproduct* @mixin \crmeb\services\copyproduct\CopyProduct*/
class CopyProduct extends BaseManager
{/*** 空间名* @var string*/protected $namespace = '\crmeb\services\copyproduct\storage\';/*** 默认驱动* @return mixed*/protected function getDefaultDriver(){return Config::get('product.default', 'copy');}/*** 获取类的实例* @param $class* @return mixed|void*/protected function invokeClass($class){if (!class_exists($class)) {throw new \RuntimeException('class not exists: ' . $class);}$this->getConfigFile();if (!$this->config) {$this->config = Config::get($this->configFile . '.stores.' . $this->name, []);}$handleAccessToken = new AccessTokenServeService($this->config['account'] ?? '', $this->config['secret'] ?? '');$handle = Container::getInstance()->invokeClass($class, [$this->name, $handleAccessToken, $this->configFile]);$this->config = [];return $handle;}}

invokeClass 里面的逻辑针对获取请求之前的逻辑做处理;AccessTokenServeService里面主要获取请求header,例如token之类的参数

使用复制商品

默认使用一号通复制商品扩展

use crmeb\services\copyproduct\CopyProduct;$copy = new CopyProduct();
//or
$copy = app()->make(CopyProduct::class);//复制商品
$goodInfo = $copy->goods($url, $options = []);var_dump($goodInfo);

使用99api复制商品扩展

use crmeb\services\copyproduct\CopyProduct;$copy = new CopyProduct('copy99api');
//or
$copy = app()->make(CopyProduct::class,['copy99api']);//复制商品
$goodInfo = $copy->goods($url, $options = []);var_dump($goodInfo);

附件:https://gitee.com/ZhongBangKeJi/CRMEB

http://www.lqws.cn/news/121141.html

相关文章:

  • 【Linux 】centos8搭建nextcloud全过程
  • 直播美颜SDK深度解析:AI人脸美型与智能美白技术揭秘
  • 机器学习实战37-基于情感字典和机器学习的股市舆情分析可视化系统
  • 微信小程序开发一个自定义组件的详细教程
  • 概念全解析:结构化数据,半结构化数据,非结构化数据分别是什么意思?
  • TPU(张量处理单元)和 TVM(张量虚拟机)深度分析
  • 分类预测 | Matlab实现CNN-BiLSTM-Attention高光谱数据分类预测
  • 【LLM大模型技术专题】「入门到精通系列教程」LangChain4j与Spring Boot集成开发实战指南
  • 美业破局:AI智能体如何用数据重塑战略决策(5/6)
  • VSCode 工作区配置文件通用模板创建脚本
  • OpenHarmony平台驱动使用(十五),SPI
  • springboot--实战--大事件--文章分类接口开发详解
  • 解决:如何在Windows adb使用dmesg | grep检查内核日志
  • 系统调试——ADB 工具
  • yum更换阿里云的镜像源
  • 【论文阅读笔记】Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation
  • 突破数据孤岛:StarRocks联邦查询实战指南
  • RDMA简介3之四种子协议对比
  • 数据结构第一章
  • git操作指南
  • layer norm和 rms norm 对比
  • 数据结构(7)—— 二叉树(1)
  • Facebook用户信息爬虫技术分析与实现详解
  • Kafka入门- 基础命令操作指南
  • springboot 微服务 根据tomcat maxthread 和 等待用户数量,达到阈值后,通知用户前面还有多少用户等待,请稍后重试
  • 数学复习笔记 25
  • CMake在VS中使用远程调试
  • OpenCV C/C++ 视频播放器 (支持调速和进度控制)
  • CentOS在vmware局域网内搭建DHCP服务器【踩坑记录】
  • 浅析EXCEL自动连接PowerBI的模板