API POST

API POST

Postby jair » Wed Mar 30, 2022 9:49 pm

Realmente necesito ayuda de colegas para hacer esta publicación de registro de producto, con el código actual del mensaje que no se informó la clave clave


Code: Select all  Expand view

//------------------------------------------------------------------------------------------------
function Send( )
   
   hCurl := curl_easy_init()
   
   cUrl := "https://bling.com.br/Api/v2/produtos/json/"
   cKey := "?apikey=81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13"
   //cKey := "apikey=81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13"
   cKey := "81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13"
   cXml:= "<produto><codigo></codigo><descricao>Caneta Preta 001 xxxx</descricao><situacao>Ativo</situacao><descricaoCurta>Descrição curta da caneta</descricaoCurta><descricaoComplementar>Descrição produto 002</descricaoComplementar><un>Pc</un><vlr_unit>1.68</vlr_unit><preco_custo>1.23</preco_custo><peso_bruto>0.2</peso_bruto><peso_liq>0.18</peso_liq><class_fiscal>1000.01.01</class_fiscal><marca>Marca da Caneta</marca><origem>0</origem><estoque>10</estoque><deposito><id>14886559917</id><estoque>200</estoque></deposito><gtin>223435780</gtin><gtinEmbalagem>54546</gtinEmbalagem><largura>11</largura><altura>21</altura><profundidade>31</profundidade><estoqueMinimo>1.00</estoqueMinimo><estoqueMaximo>100.00</estoqueMaximo><cest>28.040.00</cest><idGrupoProduto>12345</idGrupoProduto><condicao>Novo</condicao><freteGratis>N</freteGratis><linkExterno>https://minhaloja.com.br/meu-produto</linkExterno><observacoes>Observações do meu produtos</observacoes><producao>P</producao><dataValidade>20/11/2019</dataValidade><descricaoFornecedor>Descrição do fornecedor</descricaoFornecedor><idFabricante>0</idFabricante><codigoFabricante>123</codigoFabricante><unidadeMedida>Centímetros</unidadeMedida><garantia>4</garantia><itensPorCaixa>2</itensPorCaixa><volumes>2</volumes><urlVideo>https://www.youtube.com/watch?v=zKKL-SgC5lY</urlVideo><imagens><url>https://bling.com.br/bling.jpg</url></imagens><idCategoria>4573031</idCategoria></produto>"
 *  Local httpcode

   curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1 )
   curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrl + cKey )
  * curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "xxxxxxxxxx$#B<SHJGHKxxxx" + ':' + "x@#$F&^%DEE" )
   
   /* define nome de usuário e senha para autenticação */
    *curl_easy_setopt(hCurl, 26 , cKey )
    *curl_easy_setopt( hCurl, 5, cKey )
    *curl_easy_setopt(hCurl, 87, cKey)
    //CURLOPT_HTTPHEADER 23
    curl_easy_setopt(hCurl, 23, "apikey: 81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13");
   curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
   curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
*    curl_easy_setopt(hCurl, 131, cXml )
    curl_easy_setopt (hCurl, 36 , "PUT" )
    curl_easy_setopt(hCurl, 15, cXml)
   //  aqui vai o xml do PUT DELETE OU POST
  // curl_easy_setopt( hcurl, HB_CURLOPT_POSTFIELDS, Send() )  15
   nError := curl_easy_perform( hCurl )
   ? nError
*   curl_easy_getinfo( hCurl, HB_CURLINFO_RESPONSE_CODE, @httpcode )

      cResponse := curl_easy_dl_buff_get( hCurl )

  ?  cResponse
 
return NIL            


 
jair
 
Posts: 26
Joined: Sun Aug 27, 2017 7:18 pm

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 9 guests