D
Droe
Curioso
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
Hola hoy les enseñare a crear una aplicacion con diferentes resultados para hombre y mujer...
Ejemplo hombre :

Ejemplo mujer :

Lo primero que deben hacer es crear un index.php con el siguiente codigo :
Se necesita : b.ttf (Fuente), crear una carpeta para los resultados llamada "ressultado" (sin comillas), crear la imagen para hombre llamada "imagenhombre.jpg" (sin comillas), crear la imagen para mujer llamada "imagenmujer.jpg" (sincomillas), crear la imagen para los no fans llamada "nofan.jpg" (sin comillas), descargar facebook.php, base_facebook.php y el certificado aqui : https://lh.rs/wM3kePxChoxf y colocar en el directorio de la aplicación.Bueno eso es todo espero que les haya agradado mi tutorial, cualquier duda dejenlo de comentarios...Cualquier cosa este es mi fb : https://www.facebook.com/droeferb/
Ejemplo hombre :

Ejemplo mujer :

Lo primero que deben hacer es crear un index.php con el siguiente codigo :
PHP:
<?php
@set_time_limit(0);
$_APPID = 'TU ID';
$_APPSE = 'TU SECRET';
$_PERMISOS = 'publish_stream,photo_upload';
$_MSERVER = '//tuserver.com/carpeta_de_la_app/';
require 'system/facebook.php';
$facebook = new Facebook(array(
'appId' => $_APPID,
'secret' => $_APPSE,
'cookie' => true,
'fileUpload' => true,
));
$facebook->setFileUploadSupport(true);
//Obtenemos Los datos del usuario
$_R = _SR($_REQUEST['signed_request'],$_APPSE);
//Leemos el ID de la fanpage de la cual el usuario esta accediendo.
$_PAGEID = $_R['page']['id'];
//Verificamos si es fan
if($_R['page']['liked']){
if($_R['oauth_token']==""){
echo "<script>
var oauth_url = 'https://www.facebook.com/dialog/oauth/';
oauth_url += '?client_id=".$_APPID."';
oauth_url += '&redirect_uri=' + encodeURIComponent('https://www.facebook.com/pages/null/".$_PAGEID."/?sk=app_".$_APPID."');
oauth_url += '&scope=".$_PERMISOS."'
window.top.location = oauth_url;
</script>";
}else{
echo '';
$A = file_get_contents('https://graph.facebook.com/'.$_R['user_id'].'?access_token='.$_R['oauth_token']);
$A = json_decode($A,true);
/*echo '<pre>';print_r($A);*/
$url = 'http://graph.facebook.com/'.$A['id'].'/picture';
$font = 'b.ttf'; //Fuente a usar
//Funcion encargada de ver la url real de la imagen del usuario
function VerRealURL($U){
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $U);
curl_setopt($ch2, CURLOPT_HEADER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
$ZZ = curl_exec($ch2);
curl_close($ch2);
preg_match('/Location:(.*?)\n/', $ZZ, $matches);
return trim(array_pop($matches));
}
//Funcion encargada de ver que tipo de foto tiene (jpg,gif,etc)
function open_image($file){
$size = getimagesize($file);
switch($size["mime"]){
case "image/jpeg":
$im = imagecreatefromjpeg($file); //jpeg file
break;
case "image/gif":
$im = imagecreatefromgif($file); //gif file
break;
case "image/png":
$im = imagecreatefrompng($file); //png file
break;
default:
$im=false;
break;
}
return $im;
}
//Vemos la url de la foto del usuario
$url = VerRealURL($url);
//La abrimos
$image = open_image(VerRealURL('http://graph.facebook.com/'.$_R['user_id'].'/picture?type=large'));
if ($image === false) { die ('Unable to open image'); }
//Vemos el tama単o
$w = imagesx($image);
$h = imagesy($image);
//calculamos las nuevas dimensiones preservando el aspecto
$new_w=200;
$new_h=200;
if(($w/$h) > ($new_w/$new_h)){
$new_h=$new_w*($h/$w);
} else {
$new_w=$new_h*($w/$h);
}
if($A['gender']=="male"){
$image2 = imagecreatefromjpeg("imagenhombre.jpg");
}
elseif($A['gender']=="female"){
$image2 = imagecreatefromjpeg("imagenmujer.jpg");
}
//Agregamos la img del usuario al base
imagecopyResampled($image2, $image, 110, 150, 0, 0, $new_w, $new_h, $w, $h);
$font = "b.ttf";
$blanco = imagecolorallocate($image2,67,57,35);
$sombra = imagecolorallocate($image2,0,0,0);
if($A['gender']=="male"){
$delito[] = '
LADRÓN DE BESOS';
$delito[] = '
ACOSADOR DE ENANOS';
$delito[] = '
ESTAFADOR AMOROSO';
$delito[] = '
DEUDOR AFECTIVO';
$delito[] = '
MIRÓN LUJURIOSO';
$delito[] = '
MENTIROSO COMPULSIVO';
$delito[] = '
FIESTERO DESAFORADO';
$delito[] = '
ALCOHÓLICO EMPEDERNIDO';
$delito[] = '
ASESINO DE EXNOVIAS';
$delito[] = '
SECUESTRADOR DE GATOS';
}
elseif($A['gender']=="female"){
$delito[] = '
LADRONA DE BESOS';
$delito[] = '
ACOSADORA DE ENANOS';
$delito[] = '
ESTAFADORA AMOROSA';
$delito[] = '
DEUDORA AFECTIVA';
$delito[] = '
MIRONA LUJURIOSA';
$delito[] = '
MENTIROSA COMPULSIVA';
$delito[] = '
FIESTERA DESAFORADA';
$delito[] = '
ALCOHÓLICA EMPEDERNIDA';
$delito[] = '
ASESINA DE EXNOVIOS';
$delito[] = '
SECUESTRADORA DE GATOS';
}
$text2 = mt_rand(1,999).'.000 U$D DE RECOMPENSA';
$aleatorioxd= rand(0, count($delito)-1);
$fedelito= $delito[$aleatorioxd];
imagettftext($image2, 22, 0, 85, 360, $blanco, $font, $fedelito);
imagettftext($image2, 19, 0, 70, 440, $blanco, $font, $text2);
imagejpeg($image2,'resultado/tmp_'.$A['id'].'.jpg',90);
imagedestroy($image2);
echo '<div align="center" >
<br/>
<br/>
<div class="separator" style="clear: both; text-align: center;">
<div style="clear: right; float: right; margin-bottom: 10px;margin-top: 20px; margin-left: 0em;margin-right: 4em;">
<!-- Begin Ad Call Tag - Do not Modify -->
<!-- Begin Ad Call Tag - Do not Modify -->
<!-- End of Ad Call Tag -->
<!-- End of Ad Call Tag -->
</div></div>
<a href="https://www.facebook.com/profile.php?id=0" target="new"><img src="'.$_MSERVER.'resultado/tmp_'.$A['id'].'.jpg" style="margin-left: 2em; margin-right: 0em;" height="300"></a></div>
<br/>
';
$_P['message'] = trim('Cual es tu delito?.. https://www.facebook.com/pages/AppTuDelito/'.$_PAGEID.'/?sk=app_'.$_APPID.'');
$_P['source'] = "@" . realpath('resultado/tmp_'.$A['id'].'.jpg');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$_R['user_id'].'/photos?access_token='.$_R['oauth_token']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_P);
$resultado = curl_exec($ch);
$resultado = json_decode($resultado, true);
curl_close($ch);
if(is_array($resultado) && isset($resultado['id'])){
echo '';
}
}
}else{
echo '<div align="right">
<!-- Begin Ad Call Tag - Do not Modify -->
<!-- Begin Ad Call Tag - Do not Modify -->
<!-- End of Ad Call Tag -->
<!-- End of Ad Call Tag -->
<img src="nofan.jpg" height="250"></div>
<br/><br/><br/>
';
}
function _SR($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if(strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
?>
Se necesita : b.ttf (Fuente), crear una carpeta para los resultados llamada "ressultado" (sin comillas), crear la imagen para hombre llamada "imagenhombre.jpg" (sin comillas), crear la imagen para mujer llamada "imagenmujer.jpg" (sincomillas), crear la imagen para los no fans llamada "nofan.jpg" (sin comillas), descargar facebook.php, base_facebook.php y el certificado aqui : https://lh.rs/wM3kePxChoxf y colocar en el directorio de la aplicación.Bueno eso es todo espero que les haya agradado mi tutorial, cualquier duda dejenlo de comentarios...Cualquier cosa este es mi fb : https://www.facebook.com/droeferb/
Última edición: