RSS

Adding Paypal Shipping

Adding Paypal Shipping
When setting up the Paypal forms in any Allwebco template you can also add a shipping and handling option. You can also generate this code at Paypal. Login to your Paypal account and see their instructions.

Options: In the sample below we have added 3 shipping lines. You can add any 1 or all 3 to your template Paypal forms. Keep in mind that depending on your Paypal settings the “handling_cart” option below will always work and may be your only option to add.

About the options: Paypal support indicates how each of the three highlited (see below) options work:

shipping: (applies to first item added to cart)
shipping2: (applies to each additional item added to cart)
handling_cart: (applied once to cart regardless of quantity)

What to use: You can copy any one or all three highlighted lines below and add these to any Allwebco template Paypal form. The exact location in respect to the other Paypal options does not matter.
<form target=”paypal” action=”https://www.paypal.com/cgi-bin/webscr” method=”post”>
<input type=”hidden” name=”cmd” value=”_xclick”>
<input type=”hidden” name=”business” value=”your@email.com”>
<input type=”hidden” name=”quantity” value=”1″>
<input type=”hidden” name=”item_name” value=”Item1-1″>
<input type=”hidden” name=”amount” value=”35.00″>
<input type=”hidden” name=”shipping” value=”15.25″>
<input type=”hidden” name=”shipping2″ value=”1.25″>
<input type=”hidden” name=”handling_cart” value=”1.05″>
<input type=”hidden” name=”custom” value=”">
<input type=”hidden” name=”return” value=”http://yourdomain.com/thanks-payment.htm”>
<input type=”submit” value=”Add to Cart”>

You will find other Paypal setup info on your help.html if Paypal forms have been setup on your template. Also see the developers area in your Paypal account.

You will find other Paypal setup info on your help.html if Paypal forms have been setup on your template. Also see the developers area in your Paypal account.

 
Leave a comment

Posted by on October 20, 2009 in PAYMENT

 

Posting to Twitter using PHP

Like others I’ve found myself becoming something of a fan of Twitter, the impossible to explain social networking site. If you’re reading this, have a twitter account and not already my friend then add me if you like.

Apart from the interesting social aspects I’m also interested in Twitter as an API for all sorts of communications, remember Twitter already deals nicely with SMS messaging, Instant Messaging, subscription and the like and has a nice XML and JSON based API. I’ve been using the Zamano SMS gateway at work for a few projects and Twitter actually lets me some more and doesn’t come with a price tag.

I started out playing with curl to send updates like so (obviously with a real username and password):

curl -u username:password -d status="twittering from curl" http://twitter.com/statuses/update.xml

I then used the PHP curl features to do the same thing from PHP:

<?php
// Set username and password
$username = 'username';
$password = 'password';
// The message you want to send
$message = 'is twittering from php using curl';
// The twitter API address
$url = 'http://twitter.com/statuses/update.xml';
// Alternative JSON version
// $url = 'http://twitter.com/statuses/update.json';
// Set up and execute the curl process
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
// check for success or failure
if (empty($buffer)) {
    echo 'message';
} else {
    echo 'success';
}
?>

Obviously you could do more with the return than print out a success or failure message. The $buffer variable has the returned XML or JSON for you’re parsing pleasure.

I’m going to try out some of the other API methods too, probably play more with XSL or look more closely at the PEAR JSON module in building up a simple library as a quick search didn’t throw up much of interest and the API is nice and simple; making it fun to hack on.

 
Leave a comment

Posted by on October 17, 2009 in PHP

 

PHP UTF-8 cheatsheet

To support worldwide languages, you need to use UTF-8 encoding for your web pages, emails and application, rather than ISO 8859-1 or another common western encoding, since these don’t support characters used in languages such as Japanese and Chinese.

Happily, UTF-8 is transparent to the core Latin characterset, so you won’t need to convert all your data to start using UTF-8. But there are a number of other issues to deal with. In particular, because UTF-8 is a multibyte encoding, meaning one character can be represented by more one or more bytes. This causes trouble for PHP, because the language parses and processes strings based on bytes, not characters, and makes mincemeat multibyte strings – for example, by splitting characters ‘in half’, bodging up regular expressions, and rendering email unreadable.

There are a number of great articles online about UTF-8 and how it works – Joel Spolski’s comes to mind – but very few about how to actually get it working with PHP and iron out all the bugs. So, here to save you the time we put in, is a quick cheatsheet and info about a few common issues.

1. Update your database tables to use UTF-8

CREATE DATABASE db_name
CHARACTER SET utf8
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci
DEFAULT COLLATE utf8_general_ci
;

ALTER DATABASE db_name
CHARACTER SET utf8
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci
DEFAULT COLLATE utf8_general_ci
;

ALTER TABLE tbl_name
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci
;

2. Install the mbstring extension for PHP

Windows: download the dll if it’s not in your PHP extensions folder, and uncomment the relevant line in your php.ini file: extension=php_mbstring.dll
Linux: yum install php-mbstring

3. Configure mbstring

Do this in php.ini, httpd.conf or .htaccess. (Remember to prepend these with ‘php_value ‘ in httpd.conf or .htaccess.)

mbstring.language = Neutral ; Set default language to Neutral(UTF-8) (default)
mbstring.internal_encoding = UTF-8 ; Set default internal encoding to UTF-8
mbstring.encoding_translation = On ; HTTP input encoding translation is enabled
mbstring.http_input = auto ; Set HTTP input character set dectection to auto
mbstring.http_output = UTF-8 ; Set HTTP output encoding to UTF-8
mbstring.detect_order = auto ; Set default character encoding detection order to auto
mbstring.substitute_character = none ; Do not print invalid characters
default_charset = UTF-8 ; Default character set for auto content type header

4. Deal with non-multibyte-safe functions in PHP

The fast-and-loose way to do this is with the following php configuration:

mbstring.func_overload = 7 ; All non-multibyte-safe functions are overloaded with the mbstring alternatives

But there are problems with this. php.net has a warning about this potentially affecting the whole server. And even if this isn’t an issue for you, mbstring can make a mess of binary strings.

So, a better route is to search your application code for the following functions, and replace them with mbstring’s ‘slot-in’ alternatives:

mail() -> mb_send_mail()
strlen() -> mb_strlen()
strpos() -> mb_strpos()
strrpos() -> mb_strrpos()
substr() -> mb_substr()
strtolower() -> mb_strtolower()
strtoupper() -> mb_strtoupper()
substr_count() -> mb_substr_count()
ereg() -> mb_ereg()
eregi() -> mb_eregi()
ereg_replace() -> mb_ereg_replace()
eregi_replace() -> mb_eregi_replace()
split() -> mb_split()

5. Sort out HTML entities

The htmlentities() function doesn’t work automatically with multibyte strings. To save time, you’ll want to create a wrapper function and use this instead:

/**
* Encodes HTML safely for UTF-8. Use instead of htmlentities.
*
* @param string $var
* @return string
*/
function html_encode($var)
{
return htmlentities($var, ENT_QUOTES, ‘UTF-8′) ;
}

6. Check content-type headers

Check through your code for any text-based content-type headers, and append the UTF-8 charset, so the browser knows what it’s working with:

header(‘Content-type: text/html; charset=UTF-8′) ;

You should also repeat this at the top of HTML pages:

7. Update email scripts

Email can be tricky. You’ll need to update the content-type for any emails and text-based mime parts to use UTF-8 encoding. You’ll also need to alter the way in which headers are encoded to use UTF-8. mbstring provides a function mb_encode_mimeheader() to handle this for you, but it does make a mess of address lists: you’ll need to encoding the name and address parts seperately, then compile them into an address list.

Be sure to encode the subject and other headers too – Korean speakers will tend to put Korean text for the subject.

9. Check binary files and strings

Finally, double check any binary files and strings handled by PHP, particularly uploads, downloads and encryption. In some cases it may be necessary to revert to ASCII just before a download or processing a binary string.

For Chinese Character: $string = mb_convert_encoding($string, ‘UTF-8′, ‘UTF-16′);

Use this line after after mysql_query(“SET NAMES ‘utf8′”);

The Post is Taken From: http://developer.loftdigital.com/blog/php-utf-8-cheatsheet

Thanks to Nick Nettleton

 
Leave a comment

Posted by on October 8, 2009 in PHP

 

Tags: ,

Bangla Unicode Converter

Instructions:
Open a Sutonny Bangla Word document in Wordpad (not Word! Word will damage the Bangla when you copy it. when your office is 2000/2002. Office 2003 has no problem). To do that, right click the document, and select “Open with..” and “Wordpad” from the menu. Select Bangla text to be converted from Wordpad document and paste it into the box above. Click the button “Convert and display in Unicode”. In a few moments, you will see the converted text. Save the resulting webpage for further use. You can just copy and paste the text from here in to your developing web page.

Convert here:  http://thpbd.org/bangla/v3.0/index.html

 
Leave a comment

Posted by on October 7, 2009 in PHP

 

Sign up for the Google AJAX Feed API

The Google AJAX Feed API lets you download any public Atom or RSS feed using only JavaScript. A single Google API key is valid within a single directory on your web server, including any subdirectories. Signing up the URL http://www.mysite.com/mydir, for example, will create a key usable within all URLs in the http://www.mysite.com/mydir/ directory. See the API documentation for more information. You must have a Google Account to obtain a Google API key, and your API key is tied directly to your Google Account. You can generate multiple API keys for your account if you have multiple web sites.

Link: http://code.google.com/apis/ajaxfeeds/signup.html

 
Leave a comment

Posted by on October 6, 2009 in GOOGLE

 

Shareasale product data feed

ShareASale Product Datafeed for Affiliates

ShareASale is an affiliate network in the United States for small to medium size advertisers. ShareASale is the only network in the United States that does not allow affiliates to utilize desktop software to promote advertiser offers (such as browser toolbars and similar tools). ShareASale provides product data feeds via FTP to affiliates free of charge, but the advertiser has to enable feed access to affiliates manually and pay a nominal $1 activation fee per affiliate (one-time fee). The product data feed provided by ShareASale has the following format and structure:

Format: Delimited

Column Delimiter: Pipe/Vertical Bar

Row Delimited: CR + LF (Windows Line Break)

Text Qualifier: None

Header Row with Column Definition:

ProductID|Name|MerchantID|Merchant|Link|Thumbnail|BigImage|Price|RetailPrice|Category|SubCategory|

Description|Custom1|Custom2|Custom3|Custom4|Custom5|Manufacturer|PartNumber|MerchantCategory|

MerchantSubcategory|ShortDescription|ISBN|UPC|LastUpdated|status

Notes:

Columns in red color are new.

The Information for a product will be in a single line. The Line break in the example was only added for display purposes. The Download via Web Interface has the Header Row included and the (your) Affiliate ID is already encoded in the Link. The Feeds via FTP do not have the Header Row. Also the Links require the replacement of the string: YOURUSERID with the (your) ShareASale Affiliate ID.

To learn about the meaning of the columns in the feed, have a look at the Feed Definition for Merchants below.

It is very similar to the feed provided to Affiliates, because it is basically the basis for the Affiliate Datafeed.

There are three ways to access datafeeds through ShareASale.com.

1. File Download via the ShareASale.com Website

2. FTP Download via the ShareASale FTP Server

3. Real Time XML feed for Premier Affiliates

Flat File Download

Datafeed flies can be downloaded in a pipe separated format (|) from the ShareASale website.

Click the “Datafeeds Available” page to download files.

FTP Datafeeds

Datafeeds are available from the ShaerASale.com FTP server. You will need approval from each merchant partner to access the datafeed via FTP. The FTP server is at:

Address: datafeeds.shareasale.com

Port: 21

Username: Your ShareASale Username

Password: Your ShareASale Password

You can request access from the Datafeeds Available page and view your current approvals from the FTP Access for Datafeeds page.

You have to apply for FTP Access for each Merchant individually. Each activation (per Affiliate Account) cost the Merchant $1. Tip: If you apply for Feed access via FTP, explain why you need it and what you want to do with it. It helps to get approved.

Download Automation and DB Import

Downloading and processing datafeeds is a pain that can be automated.

Check out the free PHP and MySQL database automation script by Shawn “mobilebadboy” Kerr to ftp download feeds and import them into MySQL automatically on a frequent basis.

ShareASale Product Datafeed for Merchants

Please contact ShareASale via Email to enable automatic/sheduled uploads of your Product Datafeed, if you require it. The Datefeed file that needs to be sent to ShareASale has the following specifications.

  • CSV (Comma Separated Values) File = Comma Delimited text file
    • with Windows line breaks (CR LF/chr(13)+chr(10)) as Row Delimited
    • and Double Quotes (“) as Text Qualifier.
  • The first column has to contain the column header labels.

It has to look like this (columns in red color are new):

“SKU”,”Name”,”URL to product”,”Price”,”Retail Price”,”URL to image”,

“URL to thumbnail image”,”Commission”,”Category”,”SubCategory”,”Description”,

“SearchTerms”,”Status”,”Your MerchantID”, “Custom 1″, “Custom 2″, “Custom 3″,

“Custom 4″, “Custom 5″,”Manufacturer”,”PartNumber”,”MerchantCategory”,

“MerchantSubcategory”,”ShortDescription”,”ISBN”,”UPC”

Please note that each product should be on one line, no line breaks (note that there are line breaks in this example for readability reasons).

An Example:

“1183-4888″,”Shareasale.com Product 1″,

“http://www.shareasale.com”,”199.00″,”500.00″,”http://www.shareasale.com/image1.gif”,

“http://www.shareasale.com/image2.gif”,”100.00″,”4″,”32″,”This is a description of the product”,

“Listing some search terms here”,”instock”,”47″,”Custom Field”,”Custom Field”,”Custom Field”,

“Custom Field”,”Custom Field”,”Producer Inc.”,”PROD123″,”Stuff”,

“Stuff for Buffs”,”This is a short product description.”,”978-0-00000-000-0″,”123456789012″

The Pipe character (|) is a reserved character and should not appear anywhere in your file.

Any double quotes in your data (“) should be escaped by doubling them. For example, the product name

Frame, 13″ square Would be written: “SKU”,“Frame, 13″” square”,”Product URL” …

Ref: http://www.cumbrowski.com/CarstenC/affiliatemarketing_datafeeds_shareasale.asp

 
Leave a comment

Posted by on October 6, 2009 in PHP

 

Preloading Images Using CSS

http://www.bloggingdeveloper.com/post/Preloading-Images-Using-CSS.aspx

Image preloading with CSS can be achieved by a simple <div> with style “display:none;” containing all <img> tags of images to be preloaded.

<div style=”display:none;”>
<img src=”/images/imageA.jpg” >
<img src=”/images/imageB.jpg” >
</div>

The CSS preloading code must be in the BODY area of the HTML code. It will not work in the HEAD section. The optimum position depends on how the preloaded images will be used. If the images will be used sometime after the web page has finished loading, the preload <div> can be placed below the page content. If the images will be used immediately, such as automatic background image change, the preload <div> should be placed on the top section of the BODY area.

 
Leave a comment

Posted by on October 3, 2009 in CSS

 

Formats available on Youtube

Don’t confuse the formats with the videos you watch on youtube, you obviously don’t watch 3GP or 215×240 size video.However, this trick may be used inorder to view HD and HQ quality videos, that will make some difference to the video you watch.Otherwise the formats are used generally for downloading you tube videos.

Example: To download video in 3GP Format add &fmt=17 to your existing Youtube URL

fmt=5 – This seems to be the default YouTube format for download.

  • Sound: Mono, 22KHz
  • Max Best Resolution: 320×240
  • Video Output Format: FLV
  • Sound Output Format: FLV/MP3
  • Video Download Format: FLV

fmt=13- This is the low quality 3GP for mobiles.

  • Sound: Mono, 8KHz
  • Max Best Resolution: 176×144
  • Video Output Format: 3GP
  • Sound Output Format: H263/SAMR
  • Video Download Format: 3GP

fmt=17 – This is the one used for commonly downloading videos for your mobile

  • Sound: Mono, 22KHz
  • Max Best Resolution: 176×144
  • Video Output Format: 3GP
  • Sound Output Format: MPEG4/AAC
  • Video Download Format: 3GP

fmt=0 – fmt 5/0 show up the same to me, but they must be slightly different.

  • Sound: Mono, 22KHz
  • Max Best Resolution: 320×240
  • Video Output Format: FLV
  • Sound Output Format: FLV/MP3
  • Video Download Format: FLV

fmt=6 – except for the sound this one is almost the same as default format.

  • Sound: Mono, 44KHz
  • Max Best Resolution: 480×360
  • Video Output Format: FLV
  • Sound Output Format: FLV/MP3
  • Video Download Format: FLV

fmt=34 – Agian, alomost same as default format except for the sound output format.

  • Sound: Stereo, 22KHz
  • Max Best Resolution: 320×240
  • Video Output Format: FLV
  • Sound Output Format: H264/AAC
  • Video Download Format: FLV

fmt=35 – this is the High Quality FLV format available only for selected videos, the one with the HQ Symbol

  • Sound: Stereo, 44KHz
  • Max Best Resolution: 640×480
  • Video Output Format: FLV
  • Sound Output Format: H264/AAC
  • Video Download Format: FLV

fmt=18 – This is the normal High Quality MP4 format available for all videos.

  • Sound: Stereo, 44KHz
  • Max Best Resolution: 480×360
  • Video Output Format: FLV
  • Sound Output Format: H264/AAC
  • Video Download Format: MP4

fmt=22 – This is the HD Quality available for only certain videos, the one with that HD Symbol

  • Sound: Stereo, 44KHz
  • Max Best Resolution: 1280×720
  • Video Output Format: MP4
  • Sound Output Format: H264/AAC
  • Video Download Format: MP4

YouTube’s three highest quallity formats are 18/22 and 35 The highest Quality video’s is obviously HD and use: fmt=22, if the video is actually HD you would see a red HD symbol appear on the flash player next to the button for fullscreen.

The second best quality is: fmt=35, third best is: fmt=18, these are considered to be HQ, High Quality, however this on some videos is not actually true it seems to make fmt=18 better than fmt=35. On HQ you would see instead of the red HD, you would see a red HQ

 
Leave a comment

Posted by on October 2, 2009 in PHP

 

Tags:

Object-Oriented CSS

How do you scale CSS for millions of visitors or thousands of pages? Nicole first presented Object Oriented CSS at Web Directions North in Denver. Since then, the response has been overwhelming. OOCSS allows you to write fast, maintainable, standards-based front end code. It adds much needed predictability to CSS so that even beginners can participate in writing beautiful websites.

Two main principles

  1. Separate structure and skin
  2. Separate container and content

Links:
http://wiki.github.com/stubbornella/oocss
http://oocss.org/

 
Leave a comment

Posted by on October 2, 2009 in CSS

 

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

 
1 Comment

Posted by on January 2, 2008 in Uncategorized

 
 
Follow

Get every new post delivered to your Inbox.