DJ22T
DJ22T

Reputation: 1640

MercadoPago Test user

I'm struggling to create some test users for the button.

Following these instructions

Create test users

This code is supposed to be used to get the tests users, but i have no idea where to use that, or how, and the documentation is kinda poor

Request - Curl

curl -X POST \
-H "Content-Type: application/json" \
'https://api.mercadolibre.com/users/test_user?access_token=your_access_token' \
-d '{"site_id":"MLA"}'

The website is made in PHP

Any bit of advice?

Upvotes: 0

Views: 1753

Answers (1)

Hmmm
Hmmm

Reputation: 1764

This is curl used from the command line you can change this to a php file assuming that curl is enabled.

<?php

// add your access token
$access_token = "your_access_token";
$data = array('site_id' => 'MLA');

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL,"https://api.mercadolibre.com/users/test_user?access_token=$access_token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);

$response = curl_exec($ch);

// json response    
echo $response;

you can convert the json $response to an array using json_decode() and process the data

sample output

  {
    "id": 123456,
    "nickname": "TT123456",
    "password": "qatest123456",
    "site_status": "active",
    "email": "[email protected]"
}      

Upvotes: 3

Related Questions