Archive for the ‘Google’ Category

session_start() php when to do it again!

Thursday, April 29th, 2010

I was stuck for a bit there.

I have a page that loads via AJAX, but I had to modify it to work for Google’s googlebot #! system…

The googlebot logic senses that it’s googlebot, and uses PHP includes instead of the AJAX!

Well the includes don’t need the session_start() again, but the AJAX loads DO!

So, NOT to be forgotten, session_start() will work per LOAD, hard to explain that, but you can wrap your head around it…

fancy!

BETTER SOLUTION: Sessions manager class, framework or similar…

Googlebot make your AJAX crawlable #! simply explained

Tuesday, April 13th, 2010

http://code.google.com/web/ajaxcrawling/

But what?

Put simply, in your URLs, that are currently:

http://www.site.com/index.php#page90

First, make them:

http://www.site.com/index.php#!page90

Your Javascript will just see the ! (bang) as a character, it won’t care, and will continue to work just fine

Googlebot though, sees the ! and changes its query to:

http://www.site.com/index.php?_escaped_fragment_=page90

So your index simply needs to see $_GET['_escaped_fragment_']

If it’s set, load page90 via PHP instead of AJAX, and there you have it,

now Google will link the content it found via:

http://www.site.com/index.php?_escaped_fragment_=page90

to the url:

http://www.site.com/index.php#!page90

Now alter/resubmit your Google Sitemap so that all your URLs are current (WITH the #!) and you’re set!

AWESOME!

Sending mail xampp gmail

Thursday, January 1st, 2009

source/reference:

http://expertester.wordpress.com/2010/07/07/how-to-send-email-from-xampp-php/

If you’re developing on your local xampp environment, eventually you will need your apps to actually send mail:

Change the following lines in your php.ini
(usually here C:\xampp\php\php.ini, but possibly also php5.ini, and/or C:\xampp\apache\bin\php.ini):

SMTP = smtp.gmail.com
smtp_port = 587
sendmail_from = [your_gmail_username]@gmail.com]
sendmail_path = “:\”C:\xampp\sendmail\sendmail.exe\” -t”

Change your sendmail.ini to read as follows (again, usually C:\xampp\sendmail\sendmail.ini):

account Gmail
tls on
tls_certcheck off
host smtp.gmail.com
from [your_gmail_username]@gmail.com]
auth on
user [your_gmail_username]@gmail.com]
password [your_gmail_username]@gmail.com
port 587
account default : Gmail

Simple example test script to see that it worked:

<?php
$from_name = “yourName”;
$from_email = “whichEver@gmail.com”;
$headers = “From: $from_name <$from_email>”;
$body = “Hi, \nThis is a test mail from $from_name <$from_email>.”;
$subject = “Mail from my development environment”;
$to = “yourUserNameHere@gmail.com”;

if (mail($to, $subject, $body, $headers)) {
echo “success!”;
} else {
echo “fail…”;
}
?>