marcelomm

Members
  • Content Count

    8
  • Joined

  • Last visited

About marcelomm

  • Rank
    Newbie

Recent Profile Visitors

576 profile views
  1. Quando tento publicar com frete gratis ocorre este erro: Shipping method ids [100009] are not allowed for shipping mode [me2] Meu array: Array ( [title] => Teste 1 [category_id] => MLB3946 [price] => 2.00 [currency_id] => BRL [available_quantity] => 9 [buying_mode] => buy_it_now [listing_type_id] => bronze [condition] => new [description] => Teste 1 [video_id] => [warranty] => [pictures] => Array ( [0] => Array ( [source] => http://www.domain.com/images/9003073-690-800.jpg ) ) [shipping] => Array ( [mode] => me2 [local_pick_up] => false [free_methods] => Array ( [0] => Array ( [id] => 100009 [rule] => Array ( [free_mode] => exclude_region [value] => Array ( [0] => BR-NO [1] => BR-NE ) ) ) ) ) ) Acessando a categoria https://api.mercadolibre.com/categories/MLB3946 e https://api.mercadolibre.com/users/USER_ID/shipping_modes?category_id=MLB3946 informa que está liberado me2 "shipping_modes": - [... "custom", "me1", "me2", "not_specified", ], "mode": "me2", "shipping_attributes": - {... "dimensions": "clear", "costs": "not_allowed", "free": - {... "methods": "optional", "accepted_methods": - [... 100009, 182, ],
  2. Consegui resolver este erro alterando de: public static $CURL_OPTS = array( CURLOPT_USERAGENT => "MELI-PHP-SDK-1.0.0", CURLOPT_SSL_VERIFYPEER => false, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => 1, CURLOPT_TIMEOUT => 60 Para: public static $CURL_OPTS = array( CURLOPT_USERAGENT => "MELI-PHP-SDK-1.0.0", CURLOPT_SSL_VERIFYPEER => false, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => 1, CURLOPT_TIMEOUT => 60, CURLOPT_SSLVERSION => 3 Obrigado a todos.
  3. Está ocorrendo este erro: {"message":"Error validating grant. Your authorization code or refresh token may be expired or it was already used.","error":"invalid_grant","status":400,"cause":null} Estranho que retornar apenas os dados: [access_token] => [expires_in] => 1410925800 [refresh_token] => Segue meu código: _example_login.php require 'admin/MercadoLivre/meli.php'; $meli = new Meli(MERCADO_LIVRE_APP_ID, MERCADO_LIVRE_SECRET_KEY, $_SESSION['access_token'], $_SESSION['refresh_token']); if($_GET['code'] || $_SESSION['access_token']) { // If code exist and session is empty if($_GET['code'] && !($_SESSION['access_token'])) { // If the code was in get parameter we authorize $user = $meli->authorize($_GET['code'], 'http://www.meudominio.com/_example_login.php'); // Now we create the sessions with the authenticated user $_SESSION['access_token'] = $user['body']->access_token; $_SESSION['expires_in'] = time() + $user['body']->expires_in; $_SESSION['refresh_token'] = $user['body']->refresh_token; } else { // We can check if the access token in invalid checking the time if($_SESSION['expires_in'] < time()) { try { // Make the refresh proccess $refresh = $meli->refreshAccessToken(); // Now we create the sessions with the new parameters $_SESSION['access_token'] = $refresh['body']->access_token; $_SESSION['expires_in'] = time() + $refresh['body']->expires_in; $_SESSION['refresh_token'] = $refresh['body']->refresh_token; } catch (Exception $e) { echo "Exception: ", $e->getMessage(), "\n"; } } } echo '<pre>'; print_r($_SESSION); echo '</pre>'; } else { echo '<a href="' . $meli->getAuthUrl('http://www.meudominio.com/_example_login.php') . '">Login using MercadoLibre oAuth 2.0</a>'; } admin/MercadoLivre/meli.php <?php class Meli { /** * @version 1.0.0 */ const VERSION = "1.0.0"; /** * @var $API_ROOT_URL is a main URL to access the Meli API's. * @var $AUTH_URL is a url to redirect the user for login. */ protected static $API_ROOT_URL = "https://api.mercadolibre.com"; protected static $AUTH_URL = "http://auth.mercadolivre.com.br/authorization"; protected static $OAUTH_URL = "/oauth/token"; /** * Configuration for CURL */ public static $CURL_OPTS = array( CURLOPT_USERAGENT => "MELI-PHP-SDK-1.0.0", CURLOPT_SSL_VERIFYPEER => false, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => 1, CURLOPT_TIMEOUT => 60 ); protected $client_id; protected $client_secret; protected $redirect_uri; protected $access_token; protected $refresh_token; /** * Constructor method. Set all variables to connect in Meli * * @param string $client_id * @param string $client_secret * @param string $access_token * @param string $refresh_token */ public function __construct($client_id, $client_secret, $access_token = null, $refresh_token = null) { $this->client_id = $client_id; $this->client_secret = $client_secret; $this->access_token = $access_token; $this->refresh_token = $refresh_token; } /** * Return an string with a complete Meli login url. * NOTE: You can modify the $AUTH_URL to change the language of login * * @param string $redirect_uri * @return string */ public function getAuthUrl($redirect_uri) { $this->redirect_uri = $redirect_uri; $params = array("client_id" => $this->client_id, "response_type" => "code", "redirect_uri" => $redirect_uri); $auth_uri = self::$AUTH_URL."?".http_build_query($params); return $auth_uri; } /** * Executes a POST Request to authorize the application and take * an AccessToken. * * @param string $code * @param string $redirect_uri * */ public function authorize($code, $redirect_uri) { if($redirect_uri) $this->redirect_uri = $redirect_uri; $body = array( "grant_type" => "authorization_code", "client_id" => $this->client_id, "client_secret" => $this->client_secret, "code" => $code, "redirect_uri" => $this->redirect_uri ); $opts = array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body ); $request = $this->execute(self::$OAUTH_URL, $opts); if($request["httpCode"] == 200) { $this->access_token = $request["body"]->access_token; if($request["body"]->refresh_token) $this->refresh_token = $request["body"]->refresh_token; return $request; } else { return $request; } } /** * Execute a POST Request to create a new AccessToken from a existent refresh_token * * @return string|mixed */ public function refreshAccessToken() { if($this->refresh_token) { $body = array( "grant_type" => "refresh_token", "client_id" => $this->client_id, "client_secret" => $this->client_secret, "refresh_token" => $this->refresh_token ); $opts = array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body ); $request = $this->execute(self::$OAUTH_URL, $opts); if($request["httpCode"] == 200) { $this->access_token = $request["body"]->access_token; if($request["body"]->refresh_token) $this->refresh_token = $request["body"]->refresh_token; return $request; } else { return $request; } } else { $result = array( 'error' => 'Offline-Access is not allowed.', 'httpCode' => null ); return $result; } } /** * Execute a GET Request * * @param string $path * @param array $params * @return mixed */ public function get($path, $params = null) { $exec = $this->execute($path, null, $params); return $exec; } /** * Execute a POST Request * * @param string $body * @param array $params * @return mixed */ public function post($path, $body = null, $params = array()) { $body = json_encode($body); $opts = array( CURLOPT_HTTPHEADER => array('Content-Type: application/json'), CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body ); $exec = $this->execute($path, $opts, $params); return $exec; } /** * Execute a PUT Request * * @param string $path * @param string $body * @param array $params * @return mixed */ public function put($path, $body = null, $params) { $body = json_encode($body); $opts = array( CURLOPT_HTTPHEADER => array('Content-Type: application/json'), CURLOPT_CUSTOMREQUEST => "PUT", CURLOPT_POSTFIELDS => $body ); $exec = $this->execute($path, $opts, $params); return $exec; } /** * Execute a DELETE Request * * @param string $path * @param array $params * @return mixed */ public function delete($path, $params) { $opts = array( CURLOPT_CUSTOMREQUEST => "DELETE" ); $exec = $this->execute($path, $opts, $params); return $exec; } /** * Execute a OPTION Request * * @param string $path * @param array $params * @return mixed */ public function options($path, $params = null) { $opts = array( CURLOPT_CUSTOMREQUEST => "OPTIONS" ); $exec = $this->execute($path, $opts, $params); return $exec; } /** * Execute all requests and returns the json body and headers * * @param string $path * @param array $opts * @param array $params * @return mixed */ public function execute($path, $opts = array(), $params = array()) { $uri = $this->make_path($path, $params); $ch = curl_init($uri); curl_setopt_array($ch, self::$CURL_OPTS); if(!empty($opts)) curl_setopt_array($ch, $opts); $return["body"] = json_decode(curl_exec($ch)); $return["httpCode"] = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $return; } /** * Check and construct an real URL to make request * * @param string $path * @param array $params * @return string */ public function make_path($path, $params = array()) { if (!preg_match("/^http/", $path)) { if (!preg_match("/^\//", $path)) { $path = '/'.$path; } $uri = self::$API_ROOT_URL.$path; } else { $uri = $path; } if(!empty($params)) { $paramsJoined = array(); foreach($params as $param => $value) { $paramsJoined[] = "$param=$value"; } $params = '?'.implode('&', $paramsJoined); $uri = $uri.$params; } return $uri; } }
  4. Estou com o mesmo problema de nao retornar : [access_token] => [expires_in] => 1410925800 [refresh_token] => Por favor poderia informar onde estava o erro no código do sdk em php no meli.php ?
  5. I am getting the same error, please some one can help to fix it ? Thank you.
  6. O erro que esta ocorrendo e este: error:Unknown SSL protocol error in connection to api.mercadolibre.com:443
  7. O endereco de retorno continua o mesmo o problema e que ele se conecta a API, nao lista as vendas estou usando CURL ou file_get_contents nao ocorre nenhum erro, parece ser timeout requer um cacert.pem do mercado livre. o CURL esta habilitado no servidor. Precisava saber quais as extensoes necessarias ou requisitos do servidor para programacao PHP da API fornecida o SDK pelo ML.
  8. Migrei meu servidor e parou de funcionar a lista de vendas, quais os requerimentos do php para o SDK em php do MELI ? I migrated my server and stopped working the list of orders, what the requirements for the SDK from php in MELI? Meu codigo / My source: require 'admin/MercadoLivre/meli.php'; $meli = new Meli(MERCADO_LIVRE_APP_ID, MERCADO_LIVRE_SECRET_KEY, $_SESSION['access_token'], $_SESSION['refresh_token']); if($_GET['code'] || $_SESSION['access_token']) { // If code exist and session is empty if($_GET['code'] && !($_SESSION['access_token'])) { // If the code was in get parameter we authorize $user = $meli->authorize($_GET['code'], 'http://www.domain.com/_mercadolivre.php') . '">Login using MercadoLibre oAuth 2.0</a>'; } Obrigado. Thank you.