当前位置 : 主页 > 网络编程 > PHP >

tips-1048079-03.php

来源:互联网 收集:自由互联 发布时间:2021-06-28
tips-1048079-03.php // 请求头部$header = array( "Host: " . $this-_subDomain . ".cybozu.com:443", "X-Cybozu-API-Token: " . $this-_apiToken);$queryStr = 'company like "'. $keyword. '"';$params = "?app=$this-_appIdquery=".urlencode($queryS
tips-1048079-03.php
// 请求头部
$header = array(
    "Host: " . $this->_subDomain . ".cybozu.com:443",
    "X-Cybozu-API-Token: " . $this->_apiToken
);

$queryStr = 'company like "'. $keyword. '"';
$params = "?app=$this->_appId&query=".urlencode($queryStr)
            . "&fields[0]=". urlencode("company")
            . "&fields[1]=". urlencode("representative")
            . "&fields[2]=". urlencode("area")
            . "&fields[3]=". urlencode("address")
            . "&fields[4]=". urlencode("tel");

$url = "https://" . $this->_subDomain . ".cybozu.com/k/v1/records.json". $params;

$response = $this->_request($url, true, "get", null, $header); //curl提交
$result = json_decode($response, true);

if (count($result["records"]) > 0) {
    foreach($result["records"] as $value) {
        if ($contentStr != '') {
            $contentStr .= "\n\n";
        }
        $contentStr .= "公司名:".     $value["company"]["value"]."\n"
                        . "公司代表:". $value["representative"]["value"]."\n"
                        . "地域:".     $value["area"]["value"]."\n"
                        . "所在地:".   $value["address"]["value"]."\n"
                        . "电话:".     $value["tel"]["value"];
    }
}
else {
    $contentStr = "未找到该企业信息";
}
上一篇:tips-1048079-04.php
下一篇:tips-1048079-01.php
网友评论