Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
integration:ruby:xml_decode [2010/06/25 22:07] – created 76.172.152.195 | integration:ruby:xml_decode [2017/04/26 07:02] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 4: | Line 4: | ||
name : Datafeed Decryption Example | name : Datafeed Decryption Example | ||
description | description | ||
- | tags_tags | + | tags |
date_dt | date_dt | ||
version | version | ||
Line 12: | Line 12: | ||
====== Datafeed Decryption Example ====== | ====== Datafeed Decryption Example ====== | ||
+ | |||
+ | <WRAP important round> | ||
+ | //**Please note:**// | ||
+ | The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please [[http:// | ||
+ | </ | ||
+ | |||
===== Description ===== | ===== Description ===== | ||
A simple example of how to implement a datafeed listener in Ruby on Rails. It especially focuses on decrypting the RC4 encryption. | A simple example of how to implement a datafeed listener in Ruby on Rails. It especially focuses on decrypting the RC4 encryption. | ||
===== Installation ===== | ===== Installation ===== | ||
- | - Create a new **Datafeeds controller** with the code below or paste the method into your own controller. | + | |
- | - Edit the **API_KEY** with the API key from your own store. | + | - Edit the **API_KEY** with the API key from your own store. |
===== Requirements ===== | ===== Requirements ===== | ||
- | * You must have [[http:// | + | |
- | * You must have [[http:// | + | * You must have [[http:// |
- | * This example is for a v060 datafeed. It may have to be adapted for any other version. | + | * This example is for a v060 datafeed. It may have to be adapted for any other version. |
===== Gotchas ===== | ===== Gotchas ===== | ||
- | * Be sure to use **CGI:: | + | |
- | * If you get an **InvalidAuthenticityToken** error you'll have to disable | + | * If you get an **InvalidAuthenticityToken** error in Rails you'll have to disable **protect_from_forgery** for the action being called. |
===== Code ===== | ===== Code ===== | ||
Line 38: | Line 43: | ||
def create | def create | ||
| | ||
- | require 'ruby/rc4' | + | require ' |
require ' | require ' | ||
| | ||
- | decryptor = RubyRc4.new(API_KEY) | + | decryptor = RC4.new(API_KEY) |
- | xml = decryptor.encrypt(CGI:: | + | xml = decryptor.decrypt(CGI:: |
| | ||
feed = Nokogiri:: | feed = Nokogiri:: |