2db47680
hexiaodong
chore: 初始提交 php 遗...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
<?php
namespace addons\qingdong\controller;
use addons\qingdong\model\Amodel;
use addons\qingdong\model\Customer;
use Complex\Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
class Test extends StaffApi
{
protected $noNeedLogin = ['*'];
public function index(){
//$data2 = Amodel::where('bill_id' , 19)->where('type','goods')->find();
$data2['json'] = '[{"no":1,"productName":"\u9ed8\u8ba4\u5546\u54c1","markingModel":"\u9ed8\u8ba4","brand":"","unit":"\u4e2a","qty":1,
"unitPrice":"100","amount":"100","productParameter":"","productPicture":""}]';
$client = new Client();
$headers = [
'Content-Type' => 'application/json'
];
$url = 'http://113.250.185.56:8089/api/office/excel';
//halt(json_decode($data2['json'], true));
$body = [
'email' => 'bosiny@bosiny.com',
'contacts'=>'ss',
'mobile' => 'ss',
'items' =>json_decode($data2['json'], true),
];
$request = new Request('POST', $url, $headers, json_encode($body));
$res = $client->sendAsync($request)->wait();
$this->success('',$res->getBody()->getContents());
}
public function index2(){
//$data2 = Amodel::where('bill_id' , 60)->where('type','contract')->find();
$data2['json'] = '{"\u7532\u65b9":"\u535a\u897f\u5c3c\u4fe1\u606f\u79d1\u6280\u6709\u9650\u516c\u53f8","\u4e59\u65b9":"\u56db\u5ddd\u6d77\u94ed\u7535\u5b50"}';
$client = new Client();
$headers = [
'Content-Type' => 'application/json'
];
$url = 'http://113.250.185.56:8089/api/office';
$body = array(
'downName' => '',
'content' => $data2['json'],
'templateName' => ''
);
//halt(json_encode($body));
$request = new Request('POST', $url, $headers, json_encode($body));
$res = $client->sendAsync($request)->wait();
$this->success('',$res);
}
public function index3(){
$url = 'http://113.250.185.56:8089/api/office/excel';
$data2['json'] = '[{"no":1,"productName":"\u9ed8\u8ba4\u5546\u54c1","markingModel":"\u9ed8\u8ba4","brand":"","unit":"\u4e2a","qty":1,
"unitPrice":100,"amount":100,"productParameter":"\u9ed8\u8ba4\u5546\u54c1","productPicture":"\u9ed8\u8ba4\u5546\u54c1"}]';
$body = json_encode([
'email' => 'bosiny@bosiny.com',
'contacts'=>'ss',
'mobile' => 'ss',
'items' =>$data2['json'],
]);
// 初始化 cURL
$curl = curl_init($url);
// 设置 cURL 选项
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($body)
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// 执行 cURL 请求并获取响应
$response = curl_exec($curl);
// 关闭 cURL 资源
curl_close($curl);
// 处理响应
echo $response;
}
}
|