Shopify API from external app? (backbone.js) - api

I'm working with a client to develop two sites: a site with general information about their business, and a separate e-commerce store to sell the products they offer. To my knowledge, this is a fairly common approach, since often a client's CMS needs are outside the scope of what most e-commerce platforms offer.
The main site will need to show some of the products in the store, so I'm looking for e-commerce platforms that have an API. Shopify caught my eye since it has APIs which return JSON. I'm going to be building the main site with Backbone.js with a Sinatra backend.
Can anyone tell me if the Shopify API can be used this way? I also see a somewhat flimsy and uncustomizable Shopify app called Shopify Widget, which I don't think will serve my client's purposes. How would you handle this situation?

You'll have to use the sinatra app as a proxy to the Shopify store since cross-domain calls via Javascript won't work.
You can use the ShopifyAPI gem to do most of your heavy lifting and if you really wanted you could write up a ghetto RestAPI in Sinatra so you aren't re-inventing the Shopify wheel.
It could be something simple like:
POST /shopify.json
{
"model": "ShopifyAPI::Product",
"data": { ..shop data... }
}
And you can probably use const_get to retrieve the actual model you would need.

If you are using Sinatra as a backend, you can indeed do cross-domain Ajax calls. I do it all the time. Simply use Rack-Cors gem, if you want to use CORS. If you're squeamish about that due to IE having problems doing CORS, you can always return JSONP as a substitute. If your Sinatra backend runs on a subdomain, you can do whatever since there is no cross-domain issue.

Related

Storefront event webhooks in Shopware 6 app development

I developing an app and basicly if an user loaded a product in the storefront it should send a request to my server. So i thought thats possible with webhooks. But unfortunately there is no webhook for this case.
The closest thing i could find is the product.written webhook but that seems useless for my case.
Anyone has an idea how i could realize my request?
I use Shopware 6.4.11.1 as development enviroment.
Although I have not found any appropriate webhook in the webhook events reference, this may be doable in a slightly different way, without using the Shopware App Webhook mechanic.
In the Shopware documentation there are shown ways to add Storefront scripts to an app. There is even an example for product-page-loaded. You would be able to execute some of your own code in there, but honestly I have not tried to ping external servers like this and I can't tell you that this will surely work.
You could also potentially add some custom JS code that pings your server with the appropriate info.
Unfortunately I don't think you can compel Shopware to send a request from its backend on a ProductPageLoadedEvent

How to make API for website that is not mine and also requires a login?

I'm trying to create a react native app that uses data from a website that is not mine. I need to enter a login and password to get into this website.
I was thinking about using a web scraper on the backend to accomplish this, but I wasn't sure this was the best approach or even possible. How should I go about doing this?
If you could find the API from the network tabs, then use that API instead. Web Scrapers are more prone to be unstable, you wouldn't want to change the scraper again and again if someone from the website changes something in their UI. Reach out for API first, scraper should be your last option.

Can we create plugin for shopify in php?

I am trying to develop app/plugin for shopify in PHP. Shopify is fully develped in Ruby on Rails. There are so many apps developed for shopify that are installable. I tried to search plugin for shopify that are made in PHP but couldn't find.
My question is that can we create installable app/plugin in PHP for shopify? If yes then it will support for shopify? Please clarify me.
All your interaction with Shopify is via a RESTful API. You can create your App/Plugin in any language you want. It makes zero difference to Shopify, so long as you deal with the API correctly. .Net, Python, Ruby, PHP, Go, Javascript, take your pick.
There are a couple of open-source PHP example Apps floating around out there, suitable as a starting point for your copy&paste efforts. Working with Shopify API in PHP allows you to draw from PHP samples of connecting to any other common API out there, nothing special.

do I have to register as a shopify partner?

(I am reposting this question here because I tried on the google news group and got no responses.)
I need to build a shop for my client, and the client already has a domain and a web site. I need to integrate e-commerce functionality in to the site. This is going to be done by sending AJAX requests to the API.
my question is whether I need to get a partner account for this? I am not yet going to write an app that people would install, I am just building a store for my client. how is it done?
You do not need a Shopify Partner account for this. You can instead create a "Private application" within the normal shopify admin, which will give you the api credentials you need to make stuff happen.
This article on the shopify wiki gives a good overview of the process for getting started (the first sections are most relevant in your case):
http://wiki.shopify.com/Using_the_shopify_api_gem_with_the_credentials_of_a_private_app

To build an App for an Internet site without its API and Schema

I was asked to build a control-system for a Ebay-like Finnish auction-site huuto.net.
The system would reopen closed auctions by a specific rules. It would be completely external from the main site, running at an external website.
The site is however unwilling to release its API and Schema. I know no way to build such a system without knowing its API.
How do you build an internet site without its API and Schema?
You could try some form of automatic browsing: mechanize
Edit:
Examples here.
I think you're asking about building a site that interacts with another site without using a well-defined API. Is that right?
You can interact with an external site without using an official API - in order to do so, you need to imitate a normal site visitor and send your requests to the site frontend (in much the same way as a web crawler does). Tools like hpricot, mechanize and curl can help you parse the content of pages and send requests, but in doing so your system may be quite brittle. Any change to the target site might mean you have to rewrite portions of your system.
It might be possible to get the data you need by screen scraping the site. You could perform the operations you want to do by POSTing data into their forms or using a WebClient type API to make your program act like a web browser but that's likely to be an extremely brittle solution.
Honestly though, without an API, there really is no good solution.
you either need access to the database or an API, otherwise no point in even trying.