curl / Mailing Lists / curl-library / Single Mail

curl-library

Incluir Datos para GET

From: Fischel via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 21 Dec 2018 15:13:28 +0000 (UTC)

Hola:
Necesitaria hacer un get incluyendole datos.
Cual es el CURLOPT_ que deberia usar.
Con el curl:CURL --REQUEST GET https://api.mercadopago.com/v1/payments/search -d"external_reference=9012&access_token=APP_USR-6597814349505137-101914-aa306ddf62b409ec7a276ccaa36cfb12-339169521"
Funciona correctamente con el certificado curl-ca-bundle.crt

Con el programa :
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <curl/curl.h>

int main(void)
{

  CURL *curl;
  CURLcode res;
  char error[CURL_ERROR_SIZE];

  char c, sUrl[90000];
  char sCertificado[2000]="./curl-ca-bundle.crt";

  curl_global_init(CURL_GLOBAL_ALL);

  curl = curl_easy_init();
  if(curl)
  {
    
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER ,1);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST , 1);
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error);
    strcpy(sUrl,"https://api.mercadopago.com/v1/payments/search");
    curl_easy_setopt(curl, CURLOPT_URL, sUrl);

    curl_easy_setopt(curl, CURLOPT_CAINFO ,sCertificado);
    

 
    char dd, sPost[9000];//sUrl[0]=0;
    char h, sDatoCamb[9000]="external_reference=9012&access_token=APP_USR-6597814349505137-101914-aa306ddf62b409ec7a276ccaa36cfb12-339169521";//sUrl[0]=0;
    
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS,sDatoCamb );
    curl_easy_setopt(curl, CURLOPT_HTTPGET ,sDatoCamb );
    printf("Url:%s \nDatos:%s\n", sUrl,sDatoCamb );
    
    res = curl_easy_perform(curl);
    /* Check for errors */
    if(res != CURLE_OK)
    {
      printf("Error en curl_easy_perform() %s\n",
              curl_easy_strerror(res));

    }

    /* always cleanup */
    curl_easy_cleanup(curl);

  }
  return 0;
}

Responde:

Url:https://api.mercadopago.com/v1/payments/search
Datos:external_reference=9012&access_token=APP_USR-6597814349505137-101914-aa306ddf62b409ec7a276ccaa36cfb12-339169521
* About to connect() to api.mercadopago.com port 443
*   Trying 34.232.5.129... * connected
* Connected to api.mercadopago.com (34.232.5.129) port 443
* successfully set certificate verify locations:
*   CAfile: ./curl-ca-bundle.crt
  CApath: none
* Unknown SSL protocol error in connection to api.mercadopago.com:443
* Closing connection #0
Error en curl_easy_perform() SSL connect error

Agradeceria cualquier ayuda.

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-12-21