· 7 years ago · Apr 05, 2018, 06:22 PM
1<?php
2
3$client = new http\Client;
4$request = new http\Client\Request;
5
6$body = new http\Message\Body;
7$body->append(' {
8 "parcelas": [
9 {
10 "agencia": null,
11 "data_pagamento": null,
12 "data_vencimento": "20/03/2018",
13 "forma_pagamento": "26581",
14 "idSF": "a081g0000006rk6AAA",
15 "nome_banco": null,
16 "numero_documento": null,
17 "pago": false,
18 "valor": 762.74
19 },
20 {
21 "agencia": null,
22 "data_pagamento": null,
23 "data_vencimento": "20/04/2018",
24 "forma_pagamento": "26581",
25 "idSF": "a081g0000006rk7AAA",
26 "nome_banco": null,
27 "numero_documento": null,
28 "pago": false,
29 "valor": 680.74
30 },
31 {
32 "agencia": null,
33 "data_pagamento": null,
34 "data_vencimento": "20/05/2018",
35 "forma_pagamento": "26581",
36 "idSF": "a081g0000006rk8AAA",
37 "nome_banco": null,
38 "numero_documento": null,
39 "pago": false,
40 "valor": 680.74
41 },
42 {
43 "agencia": null,
44 "data_pagamento": null,
45 "data_vencimento": "20/06/2018",
46 "forma_pagamento": "26581",
47 "idSF": "a081g0000006rk9AAA",
48 "nome_banco": null,
49 "numero_documento": null,
50 "pago": false,
51 "valor": 680.74
52 }
53 ]
54 }');
55
56$request->setRequestUrl('https://cs96.salesforce.com/services/apexrest/parcelas');
57$request->setRequestMethod('POST');
58$request->setBody($body);
59
60$request->setQuery(new http\QueryString(array(
61 'oauth_consumer_key' => '00D1g0000008gXF!AQ4AQA8cVE1XnditW18zg2pw3gLHnU8bos132n_xOzAP6Rk0.FCC4Yk1TZ.yHKqgmpDxMjtiAIcvi1BzNxSlKSjcRzEJJN8U',
62 'oauth_token' => '3MVG9AzPSkglhtpsMyddB7ZgrHc6TcGU4tO1g7EA7dn4JwtlApdwyUftnX_fbqQDtSZSe613moOrLvLQbP0Dt',
63 'oauth_signature_method' => 'HMAC-SHA1',
64 'oauth_timestamp' => '1520372492',
65 'oauth_nonce' => 'WPi09Z',
66 'oauth_version' => '1.0',
67 'oauth_signature' => 'VHb s/DuSCaGAt6UJTXRRqtJJM0='
68)));
69
70$request->setHeaders(array(
71 'postman-token' => '7aa13b45-0c5f-d36a-8060-ba2a69e95a34',
72 'cache-control' => 'no-cache',
73 'authorization' => 'OAuth 00D36000001GqnN!ARgAQMM3iOGs0vLmyAjE4a9Rz3hJinsyx0UZsqw5T6ZUl0ctp8enj8pfP4ekXRHjkziwaGFxRKwCWi5LfvQhQDfrgHHP8aso',
74 'content-type' => 'application/json'
75));
76
77$client->enqueue($request)->send();
78$response = $client->getResponse();
79
80echo $response->getBody();