miercuri, 9 noiembrie 2011

Webpage correct title, description and image when sharing on facebook

I was sharing a link on facebook and I noticed the title of the page is not correct. Went back to my page, changed my title and still no succes. It seemed facebok was cache-ing this information.
SOLUTION: To remove the cache from Facebook go to this page http://developers.facebook.com/tools/debug and enter your URL.
It would also be helpful to provide special meta tags for facebook on your web page:

<meta property="og:title" content="title" />
<meta property="og:description" content="description" />
<meta property="og:image" content="thumbnail_image" />
 
More details here: http://developers.facebook.com/docs/share/ 

If you have any questions feel free to comment here.

vineri, 28 ianuarie 2011

PHP error: Strict Standards PEAR::isError()

Last day I tried to make a script for sending mail via PHP using SMTP, the script looked something like this:


require_once "Mail.php"; 

$from = "FROMmail@mail.com"; 
$to = "TOmail@mail.com"; 
$subject = "Subject";
$body = "Body text";     

$host = "mail.mail.com"; 
$username = "FROMmail@mail.com";
$password = "mail.com_pass";
$headers = array ('From' => $from,
  'To' => $to,
   'Subject' => $subject);
$mail = new Mail();
$smtp = & $mail->factory('smtp',
array ('host' => $host,
     'auth' => true,
     'username' => $username,
     'password' => $password));
if(PEAR::isError($smtp->send($to,$headers,$body)))
{
$error = $mail->getMessage();
}
else 
{
$msg = 'Mail send';
} 
The code above generated a bunch of Strict Standards errors, like the one here:


Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /usr/share/php/Net/SMTP.php


As the error states the Pear::isError is called statically but the function was not declared as so. This is probably because of a compatibility issue between PHP 4 and PHP 5, and inside PEAR scripts there are a lot of calls to this PEAR::isError() and all the calls are statical.
To solve this problem you go to /usr/share/php/ open the PEAR.php file and at line 250 you will find the function isError just add static in front of the function declaration. Try again and you should see the Strict Standards errors no more.
You may find similar errors in the Mail.php file, don't be shy, go and check the files and make the appropriate changes, that's the big benefit of Open Source.