Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $params["access_token"] = "### Chave de Acesso ###";
- $data["Product"]["stock"] = 100;
- $url = "https://{api_address}/products/123?".http_build_query($params);
- ob_start();
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen(json_encode($data)))
- );
- curl_exec($ch);
- vToken:= rotina_que_captura_token
- vUrl:= https://clienteexemplo.commercesuite.com.br/web_api/products/89';
- vJsonProduct:= TJSONObject.Create;
- vJSonPut:= TJSONObject.Create;
- vJsonPut.AddPair('stock', '100');
- vJsonProduct.AddPair('Product', vJsonPut);
- vJsonToSend := TStringStream.Create(vJsonProduct.ToString, TEncoding.UTF8);
- lHTTP:= TIdHTTP.Create(nil);
- IdSSLIOHandlerSocketOpenSSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
- lHTTP.IOHandler := IdSSLIOHandlerSocketOpenSSL;
- lHTTP.Request.ContentType := 'application/json';
- lHTTP.Request.UserAgent := 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36';
- lHTTP.Request.CustomHeaders.AddValue('Authorization', 'Bearer ' + vToken);
- Result:= lHTTP.Put(vUrl, vJsonToSend);
- /products/123?".http_build_query($params);
- vUrl:= 'https://clienteexemplo.commercesuite.com.br/web_api/products/89;'
- vUrl:= 'https://clienteexemplo.commercesuite.com.br/web_api/products/89?access_token=' + vToken;
Add Comment
Please, Sign In to add comment