Calling the API from an external application

New Member
1 0 0
We're currently building a website that is tightly integrated with Shopify - in fact so tightly, that the two entities almost appear as one. One aspect of this is that some of the products, which are in collections need to appear inside the website itself. Therefore, what I've done so far is add the shopify_app plugin to my app, and generated the code with the API key and secret I've been given in the Shop prefs. However, when I try and call something like ShopifyAPI::Product.find(:all, :params => {:limit => 3}) I get the following error each time: ERROR: You have a nil object when you didn't expect it! The error occurred while evaluating nil.path Any ideas? Is this something I can even do?
Shopify Staff
Shopify Staff
49 0 1

Hi Neil!

You need to make sure that the URL of your shop get initialized as well. You can see how this is done in lib/shopify_login_protection.rb

You need to make the shopify_session method get called before you make any API call. When you use the shopify_app generator, this gets used in the home_controller using a around_filter like this:

around_filter :shopify_session, :except => 'welcome'

The Shopify API uses the ActiveResource library, and this is the conventional way this library gets used. You can learn a bit more about ActiveResource in a screencast here:

Greetings, Dennis