创建聊天室
@param array $data   key:要创建的聊天室的id；val:要创建的聊天室的name。（必传）
@return json|xml
763877
public function chatroomCreate($data = array()) {
        try{
            if(empty($data))
                throw new Exception('要加入群的用户 Id 不能为空');
            $params = array();
            foreach($data as $key=>$val) {
                $k = 'chatroom['.$key.']';
                $params["$k"] = $val;
            }
            $ret = $this->curl('/chatroom/create', $params);
            if(empty($ret))
                throw new Exception('请求失败');
            return $ret;
        }catch (Exception $e) {
            print_r($e->getMessage());
        }
    }
698318
private function toArrayData(array $data){
		foreach ($data as $key => &$val){

			if (is_object($val)){
				if ($val instanceof self){
					$val = $val->toArray();
				}
				elseif ($val instanceof DateTimeInterface) {
					$val = $val->format(self::DATE_FORMAT);
				}
				else {
					$val = (array) $val;
				}
			}

			if (is_array($val)){
				$val = $this->toArrayData($val);
			}
		}

		return $data;
	}
1188617
public static function makeXMLTree($data)
    {
        $ret = [];
        $parser = xml_parser_create();
        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
        xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
        xml_parse_into_struct($parser, $data, $values, $tags);
        xml_parser_free($parser);
        $hash_stack = [];
        $temp = [
            "invoiceNumber" => Input::get('iN'),
            "invoiceDate" => Input::get('iD')
        ];

        foreach ($values as $key => $val) {
            switch ($val['type']) {
                case 'open':
                    array_push($hash_stack, $val['tag']);
                    break;
                case 'close':
                    array_pop($hash_stack);
                    break;
                case 'complete':
                    array_push($hash_stack, $val['tag']);
                    if(!isset($val['value'])){
                        $val['value'] = $temp[$val['tag']];
                    }

                    eval("\$ret['" . implode($hash_stack, "']['") . "'] = '{$val['value']}';");
                    array_pop($hash_stack);
                    break;
            }
        }

        return $ret ;
    }
609940
public function data(array $data)
    {
        foreach ($data as $name => $rows) {
            // 允许直接传入文案，不传颜色，如 ['first' => '恭喜你购买成功！']
            if (!is_array($rows)) {
                $data[$name] = ['value' => $rows];
            }

            // 空值则显示默认值
            if ($name !== 'remark' && !$this->wei->isPresent($data[$name]['value'])) {
                $data[$name]['value'] = '-';
            }
        }

        $this->request['data'] = $data;

        return $this;
    }
979479
public function requestIdn($data = array())
    {
        if (count($data) == 0) {
            $this->errorMessage[] = 'IDN DATA: EMPTY';
            return $this->nameData();
        }
        $data['MERCHANT'] = $this->merchantId;
        $this->refnoext = $data['REFNOEXT'];
        unset($data['REFNOEXT']);

        foreach ($this->hashFields as $fieldKey) {
            $data2[$fieldKey] = $data[$fieldKey];
        }
        $irnHash = $this->createHashString($data2);
        $data2['ORDER_HASH'] = $irnHash;
        $this->idnRequest = $data2;
        $this->logFunc("IDN", $this->idnRequest, $this->refnoext);

        $result = $this->startRequest($this->targetUrl, $this->idnRequest, 'POST');
        $this->debugMessage[] = 'IDN RESULT: ' . $result;

        if (is_string($result)) {
            $processed = $this->processResponse($result);
            $this->logFunc("IDN", $processed, $this->refnoext);
            return     $processed;
        }
        $this->debugMessage[] = 'IDN RESULT: NOT STRING';
        return false;
    }
734859
protected function makeDataScript(array $data)
    {
        $script = '';
        foreach ($data as $key => $value) {
            $script .= PHP_EOL . "data.{$key} = '{$value}';";
        }

        return $script;
    }
1226439
public function to_xml($data){
        if(!is_array($data) || count($data) <= 0) throw new \Exception('xml data exception!');
        $xml = "<xml>";
        foreach ($data as $key=>$val){
            if (is_numeric($val)){
                $xml.="<".$key.">".$val."</".$key.">";
            }else{
                $xml.="<".$key."><![CDATA[".$val."]]></".$key.">";
            }
        }
        $xml.="</xml>";
        return $xml;
    }
265117
protected function getId(array $data)
    {
        $result = null;

        if (isset($data['id'])) {
            $result = $data['id'];
        } elseif (isset($data['name'])) {
            $result = $data['name'];
        } else {
            #$result = sha1($data['action'] . $data['method']);
            $result = sha1(serialize($data));
        }

        return $result;
    }
1247915
public static function createFromArray(array $data)
    {
        $self = new self();

        if (isset($data['id'])) {
            $self->setId($data['id']);
        }
        if (isset($data['name'])) {
            $self->setName($data['name']);
        }
        if (isset($data['code'])) {
            $self->setCode($data['code']);
        }

        return $self;
    }
921957
protected function unformatPayloadData(array $data)
    {
        $unformattedData = array();

        foreach ($data as $key => $value) {
            $newKey = $this->deserializeColumnName($key);

            if (is_array($value)) {
                $newValue = $this->unformatPayloadData($value);
            } else {
                $newValue = $value;
            }

            $unformattedData[$newKey] = $newValue;
        }

        return $unformattedData;
    }
1325663
public function create($data)
    {
        $dateTime = new \DateTime();

        $result = [
                'responseTime' => $dateTime->getTimestamp(),
                'requestTime' => (float) $data['requestTime']
        ];

        return new ApiJsonModel($result);
    }
30090
public function data(array $data)
        {
            foreach ($data as $key => $value) {
                $this->attributes['data-'.$key] = $value;
            }
            return $this;
        }
541707
public static function createFromData(array $data)
    {
        if (!isset($data['method'])) {
            throw new DomainException(self::REQUIRED_METHOD);
        }

        switch ($data['method']) {
            case self::AUTO:
                $scheduleInstruction = new AutoType($data);

                break;
            case self::DATE_INTERVAL:
                $scheduleInstruction = new DateIntervalType($data);

                break;
            case self::DAY_OF_MONTH:
                $scheduleInstruction = new DayOfMonthType($data);

                break;
            case self::DAY_OF_WEEK:
                $scheduleInstruction = new DayOfWeekType($data);

                break;
            case self::IMMEDIATELY:
                $scheduleInstruction = new ImmediatelyType($data);

                break;
            case self::INTELLIGENT:
                $scheduleInstruction = new IntelligentType($data);

                break;
            default:
                throw new DomainException(
                    sprintf(self::UNSUPPORTED_METHOD, implode(',', self::$availableMethods))
                );
        }

        return $scheduleInstruction;
    }
1009679
public static function buildEnEmojiData(array $data)
    {
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $data[$key] = self::buildEnEmojiData($value);
            } elseif (is_string($value)) {
                $data[$key] = self::emojiEncode($value);
            } else {
                $data[$key] = $value;
            }
        }
        return $data;
    }
1125067
public static function toXml($data): string
    {
        if (!is_array($data) || count($data) <= 0) {
            throw new InvalidArgumentException('Convert To Xml Error! Invalid Array!');
        }

        $xml = '<xml>';
        foreach ($data as $key => $val) {
            $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' :
                                       '<'.$key.'><![CDATA['.$val.']]></'.$key.'>';
        }
        $xml .= '</xml>';

        return $xml;
    }
933471
protected function jsonResponse($data)
    {
        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
        $resultJson = $this->resultJsonFactory->create();
        $resultJson->setHeader('Content-type', 'application/json', true);
        $resultJson->setData($data);
        return $resultJson;
    }
26762
public static function setDataAttributes($data)
    {
        if(is_array($data) && count($data) > 0)
        {
            $keys = array_keys($data);

            $response = '';
            foreach($keys as $key)
            {
                $response .= ' data-' . $key . '="' . $data[$key] . '"';
            }

            return $response;
        }

        return null;
    }