Ver Mensaje Individual
  #7 (permalink)  
Antiguo 16/08/2013, 20:16
SathyaSanles
 
Fecha de Ingreso: marzo-2013
Ubicación: Neuquén Capital
Mensajes: 111
Antigüedad: 11 años, 2 meses
Puntos: 8
Respuesta: Guardar imagen desde url en app de facebook conect

Acá te dejo la solucion de lo que buscás! :D Mucha suerte! Si querés saber como copiar esa imagen avisame! ;)

Código PHP:
Ver original
  1. <?php
  2. $url = 'http://graph.facebook.com/iduser/picture';
  3. $ch = curl_init();
  4.         $timeout = 0;
  5.         curl_setopt ($ch, CURLOPT_URL, $url);
  6.         curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  7.         curl_setopt($ch, CURLOPT_HEADER, TRUE);
  8.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  9.         curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  10.         // Getting binary data
  11.         $header = curl_exec($ch);
  12.         $retVal = array();
  13.         $fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));
  14.         foreach( $fields as $field ) {
  15.             if( preg_match('/([^:]+): (.+)/m', $field, $match) ) {
  16.                 $match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
  17.                 if( isset($retVal[$match[1]]) ) {
  18.                     $retVal[$match[1]] = array($retVal[$match[1]], $match[2]);
  19.                 } else {
  20.                     $retVal[$match[1]] = trim($match[2]);
  21.                 }
  22.             }
  23.         }
  24. //here is the redirect
  25. if (isset($retVal['Location'])){
  26.      $imagen = $retVal['Location'];
  27. } else {
  28.      //keep in mind that if it is a direct link to the image the location header will be missing
  29.      $imagen = $_GET[$urlKey];
  30. }
  31. ?>


SALUDOS!