|
@@ -30,7 +30,7 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
|
|
|
|
1. First create a new application in either the partners admin or your store admin. For a private App you'll need the API_KEY and the PASSWORD otherwise you'll need the API_KEY and SHARED_SECRET.
|
|
1. First create a new application in either the partners admin or your store admin. For a private App you'll need the API_KEY and the PASSWORD otherwise you'll need the API_KEY and SHARED_SECRET.
|
|
|
|
|
|
-2. For a private App you just need to set the base site url as follows (where hostname is your site)
|
|
|
|
|
|
+2. For a private App you just need to set the base site url as follows:
|
|
|
|
|
|
shop_url = "https://#{API_KEY}:#{PASSWORD}@SHOP_NAME.myshopify.com/admin"
|
|
shop_url = "https://#{API_KEY}:#{PASSWORD}@SHOP_NAME.myshopify.com/admin"
|
|
ShopifyAPI::Base.site = shop_url
|
|
ShopifyAPI::Base.site = shop_url
|
|
@@ -41,7 +41,7 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
|
|
|
|
ShopifyAPI::Session.setup({:api_key => API_KEY, :secret => SHARED_SECRET})
|
|
ShopifyAPI::Session.setup({:api_key => API_KEY, :secret => SHARED_SECRET})
|
|
|
|
|
|
-3. To access a shop's data apps need an access token from that specific shop. This is a two-stage process. Before interacting with a shop for the first time an app should redirect the user to the following URL:
|
|
|
|
|
|
+3. In order to access a shop's data, apps need an access token from that specific shop. This is a two-stage process. Before interacting with a shop for the first time an app should redirect the user to the following URL:
|
|
|
|
|
|
GET https://SHOP_NAME.myshopify.com/admin/oauth/authorize
|
|
GET https://SHOP_NAME.myshopify.com/admin/oauth/authorize
|
|
|
|
|
|
@@ -66,19 +66,21 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
|
|
|
|
and you'll get your permanent access token back in the response.
|
|
and you'll get your permanent access token back in the response.
|
|
|
|
|
|
- There is also a method to create this url for you:
|
|
|
|
- auth_url = ShopifyAPI::Session.create_auth_url("SHOP_NAME.myshopify.com", code)
|
|
|
|
|
|
+ There is a method to make the request and get the token for you, first instantiate a new session with the shop url:
|
|
|
|
|
|
-5. Use that token to instantiate a session that is ready to make calls to the given shop.
|
|
|
|
|
|
+ session = ShopifyAPI::Session.new("SHOP_NAME.myshopify.com")
|
|
|
|
+
|
|
|
|
+ Then call:
|
|
|
|
+
|
|
|
|
+ token = session.request_token(code)
|
|
|
|
|
|
- session = ShopifyAPI::Session.new("SHOP_NAME.myshopify.com", token)
|
|
|
|
- session.valid? # returns true
|
|
|
|
|
|
+ Which will request the token, save it to the session object and return it.
|
|
|
|
|
|
-6. Now you can activate the session and you're set:
|
|
|
|
|
|
+5. The session must be activated before use:
|
|
|
|
|
|
ShopifyAPI::Base.activate_session(session)
|
|
ShopifyAPI::Base.activate_session(session)
|
|
|
|
|
|
-7. Start making authorized API requests for that shop. Data is returned as ActiveResource instances:
|
|
|
|
|
|
+6. Now you're ready to make authorized API requests to your shop! Data is returned as ActiveResource instances:
|
|
|
|
|
|
shop = ShopifyAPI::Shop.current
|
|
shop = ShopifyAPI::Shop.current
|
|
|
|
|
|
@@ -100,7 +102,7 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
|
|
|
|
products = ShopifyAPI::Session.temp("SHOP_NAME.myshopify.com", token) { ShopifyAPI::Product.find(:all) }
|
|
products = ShopifyAPI::Session.temp("SHOP_NAME.myshopify.com", token) { ShopifyAPI::Product.find(:all) }
|
|
|
|
|
|
-8. Finally, you can also clear the session (for example if you want to work with another shop):
|
|
|
|
|
|
+8. If you want to work with another shop, you'll first need to clear the session::
|
|
|
|
|
|
ShopifyAPI::Base.clear_session
|
|
ShopifyAPI::Base.clear_session
|
|
|
|
|
|
@@ -111,7 +113,7 @@ This package also includes the `shopify` executable to make it easy to open up a
|
|
|
|
|
|
1. Obtain a private API key and password to use with your shop (step 2 in "Getting Started")
|
|
1. Obtain a private API key and password to use with your shop (step 2 in "Getting Started")
|
|
|
|
|
|
-2. Use the `shopify` script to save the credentials for the shop to quickly login.
|
|
|
|
|
|
+2. Use the `shopify` script to save the credentials for the shop to quickly log in.
|
|
|
|
|
|
shopify add yourshopname
|
|
shopify add yourshopname
|
|
|
|
|
|
@@ -121,7 +123,7 @@ This package also includes the `shopify` executable to make it easy to open up a
|
|
|
|
|
|
shopify console
|
|
shopify console
|
|
|
|
|
|
-4. Enter the following for the full list of the commands.
|
|
|
|
|
|
+4. To see the full list of commands, type:
|
|
|
|
|
|
shopify help
|
|
shopify help
|
|
|
|
|