I had a mildly tough time with getting my feeds sent to Google Base on a nightly schedule without doing it manually. I went through trying to use the Zend API tool, and just kept getting stuck. I then realized it was far easier to create my feed and FTP it to Google using crontab. Like anything else, if I had a problem, I’m sure someone else did as well, so I of course want to share my information.
30 01 * * * /usr/local/bin/curl http://www.mysite.com/googfeed/ftp.php
PHP Code for FTP’ing to Google
$host = "uploads.google.com"; // setup $host and $file variables for your setup before here... $hostip = gethostbyname($host); // login with username and password // IMPORTANT!!! turn passive mode on if ((!$conn_id) || (!$login_result)) { // upload a file // close the connection
$ftp_user_name = "INSERT YOUR GOOGLE FTP USERNAME"; //this does not equal your Google Account username.
$ftp_user_pass = "INSERT YOUR GOOGLE FTP PASSWORD"; //again not equal to Google Account password.
$remote_file = "google-base.xml"; //Change this to match the exact name of the file you setup in Google Base as your upload file.
$file = "/usr/home/htdocs/feed/google-base.xml"; // This need to be the full path to the filey ou want to send to google.
$conn_id = ftp_connect($hostip);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv ( $conn_id, true );
echo "FTP connection has failed!";
echo "Attempted to connect to $host for user $ftp_user_name";
die;
} else {
echo "Connected to $host, for user $ftp_user_name
“;
echo “Host IP is $hostip
“;
if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
echo “successfully uploaded $file
“;
} else {
echo “There was a problem while uploading $file
“;
}
ftp_close($conn_id);
}
?>