Google apps script

Hi,I have create a function in google apps script which get the email from an email payment.My question is now : how can i create a function which create the LimeLM key ?

Look like i have to convert the php "fastspring" function to a google code function :

function processKey(email) { // //TODO: set your API key found in http://wyday.com/limelm/settings/ $api_key = 'PASTE THE API KEY HERE';

//TODO: set the version id to generate & find keys for // the version id is found in the url. For example http://wyday.com/limelm/version/100/ // the version id is 100. $version_id = 'PASTE THE VERSION ID';

//TODO: Use any feature values here //$feature_names = array('update_expires'); //$feature_values = array('2012-06-25');

$post_data = array( 'method' => 'limelm.pkey.generate', 'version_id' => $version_id, 'num_keys' => 1, 'num_acts' => $quantity, 'email' => $email, 'api_key' => $api_key, 'nojsoncallback' => 1, 'format' => 'json' );

if ($feature_names !== null) { $post_data['feature_name'] = $feature_names; $post_data['feature_value'] = $feature_values; }

// urlencode $post_data $post_string = ''; foreach ($post_data as $key => $value) { if (is_array($value)) { foreach ($value as $sub_value) { $post_string .= $key.'[]='.urlencode($sub_value).'&'; } } else $post_string .= $key.'='.urlencode($value).'&'; } $post_string = rtrim($post_string, '& '); $request = curl_init('https://wyday.com/limelm/api/rest/'); curl_setopt($request, CURLOPT_HEADER, 0); curl_setopt($request, CURLOPT_ENCODING, ""); curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); curl_setopt($request, CURLOPT_SSL_VERIFYPEER, TRUE);

try { $jObj = json_decode(curl_exec($request)); if ($jObj->stat == 'ok') { foreach ($jObj->pkeys->pkey as $pkey) { echo $pkey->key."\r\n"; } } else { // Uncomment the next line to see the error LimeLM is giving you. //echo $jObj->message; } } catch (Exception $e) { // Uncomment the next line to see the exception. //echo 'Failure: '.$e->getMessage(); }}

When Google notifies the script on your server that a purchase was successful then generate the product key. To generate the key either use that FastSpring script or use The code that's in the PaymentSettings.php file.

When Google notifies the script on your server that a purchase was successful then generate the product key. To generate the key either use that FastSpring script or use The code that's in the PaymentSettings.php file.

But, i have multiple payment method, and this method do not use fastspring.The company send me just a email with the email of the client.I have created a google apps script to parse the email and get the email of the client in the email that i receive.

Not, i have to create a google apps script which create the LimeLM key (in google code language, not php).But i have some difficulty to convert some php code example in google code.I will appreciate your help.

Damien

Oh, OK, you're asking how to turn the FastSpring PHP script into a JavaScript that can run on Google's cloud. We don't currently have enough free time to build something for you, but here's the basics of what you need to do:

  1. Make a "POST" request to the LimeLM servers (specifically, to https://wyday.com/limelm/api/rest/)
  2. Make sure you pass the parameters to generate the product key. And since "Google script" is really just JavaScript you'll want to make LimeLM return the response in JSON format to make it easier to parse. See: JSON Response Format.
  3. Parse the response from LimeLM (either success with the keys, or failure with an error message).

Start slowly. Start with the first bullet point. Once you get an error returned from the LimeLM servers you can move on the second bullet.