• 0
diegoravera

ETIQUETAS DE ENVIO EN PHP - PDF CORRUPTO

Question

Necesito Ayuda, Obtengo el string del PDF pero no consigo obtener un PDF , me lo crea corrupto

les paso el código que uso:

 

        $order_id=$_REQUEST['order_id'];
        $itemventas = $meli -> getWithAccessToken('/orders/'.$order_id);
        $ship=$itemventas['json']['shipping']['id'];
        $itemventas = $meli -> getWithAccessToken('/shipment_labels',array('shipment_ids' => $ship, 'response_type' => 'pdf'));
        $retorno=$itemventas['body'];
        $nombre_archivo = "logs.pdf";
        file_put_contents($nombre_archivo, $retorno);

 

 

 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hola

Creo que tienes un error aqui:

$ship=$itemventas['json']['shipping']['id'];

Deberia ser, ya que la respuesta te la da en el 'body' no existe ningun objecto que se llame 'json'

$ship=$itemventas['body']->shipping->id;

No uses el SDK para obtener la guia, usa la direccion directamente

$guia = 'https://api.mercadolibre.com/shipment_labels?shipment_ids='.$ship.'&response_type=pdf&access_token='.$token

Saludos.

Edited by Fernando Aguirre

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...