Un rezultat al interogari
graph.facebook.com/me/ JSON este :
Cod: Selectaţi tot
{
"id": "100002576914528",
"name": "Criss Tian",
"first_name": "Criss",
"last_name": "Tian",
"link": "http://www.facebook.com/meleca.cristian",
"username": "meleca.cristian",
"birthday": "07/11/1993",
"hometown": {
Cod: Selectaţi tot
<?php
$app_id = "appid";
$app_secret = "Secretid";
$post_login_url = "loading.php"; //adresa curenta
$album_id = "";
$urls = array(
0 => 'Test',
);
$url = $urls[ rand(0,(count($urls)-1)) ];
$photo_caption = "".$url."";
$code = $_REQUEST["code"];
//Obtain the access_token with publish_stream permission
if (!$code){
$dialog_url= "http://www.facebook.com/dialog/oauth?"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
. "&scope=publish_stream";
echo("<script>top.location.href='" . $dialog_url
. "'</script>");
} else {
$token_url="https://graph.facebook.com/oauth/access_token?"
. "client_id=" . $app_id
. "&client_secret=" . $app_secret
. "&redirect_uri=" . urlencode( $post_login_url)
. "&code=" . $code;
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
$graph_rl = "https://graph.facebook.com/me?access_token="
. $params['access_token'];
$user = json_decode(file_get_contents($graph_rl));
echo '' . $user->name . '<br />';
echo 'Id-ul ' . $user->id . ' este al tau';
$photo_url = 'http://desehix.com/app/test/poza.php?nume=$user->name';
// POST to Graph API endpoint to upload photos
$graph_url= "https://graph.facebook.com/"
. $album_id . "/photos?"
. "url=" . urlencode($photo_url)
. "&message=" . urlencode($photo_caption)
. "&method=POST"
. "&access_token=" .$access_token;
echo file_get_contents($graph_url);
}
?>
</body>
</html>
Mie imi trebuie sa imi apara numele la variabila $photo_url pentru a genera textul in imagine de la
http://desehix.com/app/test/poza.php?nume=Marplo
Scriptul pentru generarea fotografiilor este :
Cod: Selectaţi tot
<?php
//Set the Content Type
header('Content-type: image/jpeg');
// Create Image From Existing File
$jpg_image = imagecreatefromjpeg('https://lh5.googleusercontent.com/-_aAJsgiWZjo/UN63MiooBkI/AAAAAAAAAeU/JZ7H4Pqh4Yk/s500/4.jpg');
// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 255, 255, 255);
// Set Path to Font File
$font_path = 'font.TTF';
// Set Text to Be Printed On Image
$text = $_GET['nume'];
// Print Text On Image
imagettftext($jpg_image, 15, 0, 15, 30, $white, $font_path, $text);
// Send Image to Browser
imagejpeg($jpg_image);
// Clear Memory
imagedestroy($jpg_image);
?>
Sper ca te ajuta mai bine sa intelegi ce vreau daca ti-am dat toate scripturile cu care incerc sa lucrez.