-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.php
More file actions
115 lines (105 loc) · 2.48 KB
/
test.php
File metadata and controls
115 lines (105 loc) · 2.48 KB
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
111
112
113
114
115
<?php
$parts = array(
array(
"VendorID" => "1",
"PartNumber" => "53-04855",
"Qty" => 1
),
array(
"VendorID" => "1",
"PartNumber" => "550-0138",
"Qty" => 2
),
array(
"VendorID" => "1",
"PartNumber" => "2-B10HS",
"Qty" => 3
)
);
$po = array(
"PONumber" => "1234-00",
"ShipToFirstName" => "John",
"ShipToLastName" => "Smith",
"ShipToCompany" => "ABC Lawn",
"ShipToAddress1" => "123 Peachtree St.",
"ShipToAddress2" => "",
"ShipToCity" => "Atlanta",
"ShipToState" => "GA",
"ShipToZip" => "30313",
"ShipToCountry" => "US",
"Items" => $parts
);
$url = "http://localhost:8000";
$fields = array(
'accountnumber' => '12345',
'bsvkey' => '108b6a78-4027-447b-9b2d-a6c9b7da72dc',
'dealerkey' => '0d3d6381-0e02-11e5-9eb5-20c9d0478db9',
//'dealerkey' => '',
'data' => json_encode(array($po))
);
print_r($fields);
echo "\n\n";
$field_data = "";
foreach ($fields as $key => $value)
$field_data .= "&$key=$value";
exit;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url/sendorder");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $field_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($info['http_code'] == 200) {
$pos = json_decode($result);
echo "$result\n";
foreach ($pos as $po) {
echo "Dealer's PO# $po->DealerPO\n";
echo "Merx PO# $po->MerxPO\n";
}
} else {
echo "Request Failed\n$result\n";
print_r($info);
}
exit;
/*
*/
/*
//06.03.2013 naj - get po status
$getstr = "?UUID=123&DealerKey=abc&BSVKey=abc&MerxPO=MERX-00072";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url/postatus$getstr");
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($info['http_code'] == 200) {
$pos = json_decode($result);
echo "$result\n";
print_r($pos);
} else {
echo "Request Failed\n$result\n";
print_r($info);
}
exit;
*/
//06.03.2013 naj - inventoryverify
$getstr = "?UUID=123&DealerKey=abc&BSVKey=abc&VendorID=PRTUN&PartNumber=12356";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url/inventoryverify$getstr");
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($info['http_code'] == 200) {
$pos = json_decode($result);
echo "$result\n";
print_r($pos);
} else {
echo "Request Failed\n$result\n";
print_r($info);
}
?>