2012-04-28 37 views
7
<?php 
session_start(); 
require_once 'facebook.php'; 
$app_id = "418907881455014"; 
$app_secret = "36389d2c4caaf6de86982cb87686a494"; 
$redirect_uri = 'http://gooogle12.comuf.com'; 
$facebook = new Facebook(array(
     'appId' => $app_id, 
     'secret' => $app_secret, 
     'cookie' => true 
)); 
$user = $facebook->getUser(); 
$user_profile = $facebook->api('/me'); 

$coded = $_REQUEST['code']; 

$access_token = $facebook->getAccessToken(); 
$name = "".$user_profile['name'].""; 
$fbid = "".$user_profile['id'].""; 

function RandomLine($filename) { 
    $lines = file($filename) ; 
    return $lines[array_rand($lines)] ; 
} 
$reason = RandomLine("reason.txt"); 

$canvas = imagecreatefromjpeg ("bg.jpg");         // background image file 
$black = imagecolorallocate($canvas, 0, 0, 0);       // The second colour - to be used for the text 
$font = "Arial.ttf";               // Path to the font you are going to use 
$fontsize = 20;                // font size 

$birthday = "".$user_profile['birthday'].""; 
$death = "- ".date('d/m/Y', strtotime('+'.rand(0, 10000).' days')).""; 

imagettftext($canvas, 22, -1, 110, 120, $black, $font, $name);   // name 
imagettftext($canvas, 22, -1, 110, 170, $black, $font, $birthday);  // birthday 
imagettftext($canvas, 22, -1, 255, 172, $black, $font, $death);   // death 
imagettftext($canvas, 20, -1, 110, 220, $black, $font, $reason);   // reason 


$facebook->setFileUploadSupport(true); 

//Create an album 
$album_details = array(
     'message'=> 'How will you die?', 
     'name'=> 'How will you die?' 
); 
$create_album = $facebook->api('/me/albums', 'post', $album_details); 

//Get album ID of the album you've just created 
$album_uid = $create_album['id']; 

//Upload a photo to album of ID... 

$file='img/'.$fbid.'.jpg'; //Example image file 

$photo_details = array('message'=> 'Find...51', 'image' => '@'.realpath($file)); 
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details); 


    enter code here 



ImageDestroy($canvas); 

header("Location: http://facebook.com".$fbid."&photoid=".$upphoto."") 
?> 

खैर मैं एक फेसबुक आवेदन बनाने के लिए इस php कोड का उपयोग कर रहा हूँ। मैंने अपनी वेबसाइट की मूल निर्देशिका में फ़ॉन्ट Arial.ttf अपलोड किया। लेकिन फिर भी मैं त्रुटि दिखा रहा हूं- Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/a2424901/public_html/index.php on line 35। मैंने मामले को बदलने की कोशिश की, लेकिन मैंने मेरे लिए काम नहीं किया। मैं इस कोड में गलत कहां गया?चेतावनी: imagettftext() [function.imagettftext]: /home/a2424901/public_html/index.php में/खुला फ़ॉन्ट लाइन पर नहीं मिल सका 35

उत्तर

22

From the docs

जी.डी. पुस्तकालय पीएचपी का कौन सा संस्करण के आधार पर उपयोग कर रहा है, जब fontfile साथ एक अग्रणी/तो .ttf फ़ाइल नाम से जोड़ दिए जाएंगे और पुस्तकालय है कि के लिए खोज करने का प्रयास करेंगे शुरू नहीं होता है पुस्तकालय परिभाषित फ़ॉन्ट पथ के साथ फ़ाइल नाम।

यह सूचित करते हैं कि fontfile एक निरपेक्ष पथ होना चाहिए लगता है, और अगर यह नहीं है, समारोह इसका अंत पर एक और .ttf संलग्न कर देगा।

फ़ॉन्ट फ़ाइल का पूरा पथ निर्दिष्ट करें।

$font = "/home/a2424901/public_html/Arial.ttf"; 

या .ttf छोड़ देते हैं और GDFONTPATH का उपयोग करें। The documentation निम्नलिखित की सिफारिश करता है:

कई मामलों में जहां फ़ॉन्ट का उपयोग करते हुए उसी निर्देशिका में एक फ़ॉन्ट रहता है, तो निम्न चाल किसी भी समस्या को कम कर देगी।

putenv('GDFONTPATH=' . realpath('.')); 
$font = "Arial"; 
0

आप pChart इस का उपयोग उपयोग कर रहे हैं:

$myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11)); 
3

user2724960 के जवाब देने के लिए पर जोड़ने के लिए; फ़ॉन्ट नाम को __DIR__ . '/graph/fonts/someFont.ttf' में बदलकर मेरे लिए यह किया।

पूर्ण पंक्ति:

+0

यह काम करता है, धन्यवाद। मैंने सोचा कि यह अनुमति मुद्दा था, लेकिन ऐसा नहीं है। – arjunaaji

-4

कृपया नीचे फ़ॉन्ट फ़ोल्डर के लिए जाँच:

$myPicture->setFontProperties(array("FontName"=>__DIR__ . '/graph/fonts/someFont.ttf',"FontSize"=>14)); 

अपने फ़ॉन्ट फ़ाइल ("Forgotte" डिफ़ॉल्ट) के नाम के साथ "someFont" को बदलने के लिए भूल गया न करें संसाधन।

+1

यह एक टिप्पणी होनी चाहिए, जवाब नहीं। – Tay2510

0

मुझे एक ही समस्या थी। मेरे फ़ॉन्ट नाम

Titr.TTF

था और मैं

Titr.ttf

करने के लिए इसे बदल दिया है और इसकी पूरी तरह से काम किया।