It seems that the parameter named "margin" which builds the url part "chld" differs in your implementation from what the actual google api says. ( http://code.google.com/intl/de-DE/apis/chart/infographics/docs/qr_codes....) You are expecting an int to be used but actually it should be a string.

Line 24 in qr_codes_google_chart.module should look like the following:

$url = variable_get('qr_codes_google_chart_url', 'http://chart.apis.google.com/chart') . sprintf('?cht=qr&chl=%s&chs=%dx%d&chld=%s', $data, $width, $height, $margin);

Comments

methotec’s picture

I could reproduce the margin error, too - but it seems that the origin of this is that the parameter:
chld=<error_correction_level>|<margin>
needs both: the correction level AND the margin.
So - what worked for me was (same code block):

$ec_level = 'L';
$url = variable_get('qr_codes_google_chart_url', 'http://chart.apis.google.com/chart') . sprintf('?cht=qr&chl=%s&chs=%dx%d&chld=%s|%d', $data, $width, $height, $ec_level, $margin);

As you can see - I use the int for the margin - but added the error correction level as String before that separated by the '|'.
As Google points out 'L' is the default - but has to be set nevertheless when using a margin:
Google QR-Code Syntax

Maybe in an oncoming version this cool module could allow one to set the error correction level globally?
For e.g. in QR Codes Global Settings under the cache settings.
I believe that this is a useful feature regardless of the used QR generation API.
What do you think of this?

D.H.’s picture

As described in #1 there should be an additional parameter '$ec_level' which defaults to 'L'. The google chart api differs from libQrEncode! So if you want to fix this an optional parameter named $ec_level would only make sense if libQrEncode uses that one too in the same way. For me the quick fix of rewriting %i to %s for the margin paramter was ok but is indeed quite confusing.

methotec’s picture

I'm not using libQrEncode but I am sure it has all features of the QR-Code available...
So I looked it up - and yep . .. in the header qrencode.h you can find the error correction.

/**
* Level of error correction.
*/
typedef enum {
QR_ECLEVEL_L = 0, ///< lowest
QR_ECLEVEL_M,
QR_ECLEVEL_Q,
QR_ECLEVEL_H ///< highest
} QRecLevel;

I don't have a ~nix machine at hand to test this though.
But it seems to be quite straight forward.

So - I guess because the QR-Code Standard has an error correction level - all better tools implement that, too.

But - unfortunately I can't test this here...

D.H.’s picture

It's been a while, but it would be nice if the module maintainer could give the suggestions stated here a try or at least give some response.