Giter Club home page Giter Club logo

Comments (7)

royalwang avatar royalwang commented on August 28, 2024

你的请求返回值是Null,json解析空也是Null,然后用来current取值就报参数应该是个数组,不能用Null值。

from alidayu.

flc1125 avatar flc1125 commented on August 28, 2024

是的。一般出現這種情況,是網絡原因導致的。建議在最外層增加一個try catch

from alidayu.

Tinywan avatar Tinywan commented on August 28, 2024
  • 我也是这个错误:current() expects parameter 1 to be array, null given
     * 解析返回数据
     * @return array|false
     */
    protected function parseRep($response)
    {
        if ($this->format == 'json') {
            $resp = json_decode($response);

            if (false !== $resp) {
                $resp = current($resp);
            }
        }

        elseif ($this->format == 'xml') {
            $resp = @simplexml_load_string($response);
        }

        else {
            throw new Exception("format错误...");
  • 加上 try catch 同样一样的,返回错误信息:current() expects parameter 1 to be array, null given
    protected function parseRep($response)
    {
        try {
            if ($this->format == 'json') {
                $resp = json_decode($response);
                if (false !== $resp) {
                    $resp = current($resp);
                }
            } elseif ($this->format == 'xml') {
                $resp = @simplexml_load_string($response);
            } else {
                throw new Exception("format错误...");
            }
        } catch (\Exception $e) {
            $resp = $e->getMessage();
        }

        return $resp;
    }
  • @flc1125 这个有什么办法可以解决吗?公司里是好的,结果回家就会出现这个情况

from alidayu.

Tinywan avatar Tinywan commented on August 28, 2024

@xualen 这个问题你解决了没有?

from alidayu.

flc1125 avatar flc1125 commented on August 28, 2024

这块我重新发布一个版本专门修复下吧!

from alidayu.

flc1125 avatar flc1125 commented on August 28, 2024

已修复。已更新packagist

from alidayu.

Tinywan avatar Tinywan commented on August 28, 2024

@flc1125 可以的

from alidayu.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.