{{userInfo.nickname}}
用户设置 退出登录

{{wikiTitle}}

商品采集

目前已有一号通、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);
{{cateWiki.like_num}}人点赞
0人点赞
评论({{cateWiki.comment_num}}) {{commentWhere.order ? '评论从旧到新':'评论从新到旧'}} {{cateWiki.page_view_num}}人看过该文档
评论(0) {{commentWhere.order ? '评论从旧到新':'评论从新到旧'}} 29人看过该文档
评论
{{item.user ? item.user.nickname : ''}} (自评)
{{item.content}}
{{item.create_time}} 删除
{{item.like ? item.like.like_num : 0}} {{replyIndex == index ? '取消回复' : '回复'}}
评论
{{items.user ? items.user.nickname : '暂无昵称'}} (自评)
{{items.content}}
{{items.create_time}} 删除
{{items.like ? items.like.like_num : 0}} {{replyIndexJ == (index+'|'+indexJ) ? '取消回复' : '回复'}}
评论
目录
  • {{item}}