• Magento2 中如何使用curl


    $ url =>包含端点网址。$ params =>它是一个数组,如果你想在url附加额外的参数。$ response =>它将包含json形式的输出。
     
    代码:
    /**
     * @var MagentoFrameworkHTTPClientCurl
     */
    protected $_curl;
     
    /**
     * @param Context                             $context
     * @param MagentoFrameworkHTTPClientCurl $curl
     */
    public function __construct(
        Context $context,
        MagentoFrameworkHTTPClientCurl $curl
    ) {
        $this->_curl = $curl;
        parent::__construct($context);
    }
     
    public function execute()
    {
        //if the method is get
        $this->_curl->get($url);
        //if the method is post
        $this->_curl->post($url, $params);
        //response will contain the output in form of JSON string
        $response = $this->_curl->getBody();
    }
  • 相关阅读:
    koa mog
    sdl
    基于WindowImplBase 更简单 以及 可变大小的,才是标准的
    df
    ffplay vc
    开源1bo
    react学习前一部分
    0514 react路由
    nodejs 调用进程
    Ubuntu Linux, 不要弄什么 wine,龙井 或者什么等 QQ 了。
  • 原文地址:https://www.cnblogs.com/shenlongjue/p/7525097.html
Copyright © 2020-2023  润新知