jul
16
2010

Subir archivos al facebook con php +Curl

Aquí el código como respuesta de muchas personas que me han mandado un mail para preguntarme si se puede, ahora les digo que si es posible, y sin más que decirles aquí les dejo el código fuente.


require_once 'facebook.php';

$appapikey = 'xxx';
$appsecret = 'xxx';
$facebook = new Facebook($appapikey, $appsecret);

$session_key = 'xxx'; //this is the infinite session_key returned when asking for the offline_access extended permission

$args = array(
'method' => 'facebook.video.upload',
'v' => '1.0',
'api_key' => $appapikey,
'call_id' => microtime(true),
'format' => 'JSON',
'session_key' => $session_key,
'title' => 'My video title',
'description' => 'My video description'
);

ksort($args);
$sig = '';
foreach($args as $k => $v) {
$sig .= $k . '=' . $v;
}
$sig .= $appsecret;
$args['sig'] = md5($sig);

$args["short.wmv"] = '@E:\path\to\short.wmv';

$ch = curl_init();
$url = 'http://api-video.facebook.com/restserver.php?method=facebook.video.upload';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);

$data = curl_exec($ch);

print_r($data); //returned xml here

?>

Comenten para ver como les funciono.

Related Posts

About the Author: Miguel Angel Ortega Acosta

1 Comment + Add Comment

  • Hey,
    I saw your code. First removes all cookies of previous session. cURL is a great library for file transmissions via different types of protocols. The library supports the transport via POST, GET, FTP upload and much more. The default value to file upload within PHP is 2MB, if you want bigger size than upload PHP configuration.
    Thanks
    File recovery

Leave a comment

Patrocinador

Siguenos

Suscribete

Escribe tu correo:

Recibirás un correo con todos los articulos escritos en ZoneArtCss durante el día.

Correo @zoneartcss.com

Obtén una cuenta de @zoneartcss.com gratuita