Lj Belmeska Posted April 29, 2021 Posted April 29, 2021 My PHP skills consist of your basic Loops and Functions. I don't have all the skills mentioned in the article (https://adevait.com/shopify/4-shopify-developer-skills-and-their-practical-application). I'm more of a HTML, CSS and Javascript guy. Connecting with an API using PHP (or just connecting to an API in general) is not something I've done before. I'm trying to connect to the Shopify API. Their documentation on PHP is sorely insufficient. I only got this from their documentation: <?php //Modify these $API_KEY = 'your-token-here'; $SECRET = 'your-secret-here'; $TOKEN = 'your-secret-here'; $STORE_URL = 'yourestore.myshopify.com'; $PRODUCT_ID = 'product-id-here'; $url = 'https://' . $API_KEY . ':' . md5($SECRET . $TOKEN) . '@' . $STORE_URL . '/admin/products/' . $PRODUCT_ID . '.xml'; $session = curl_init(); curl_setopt($session, CURLOPT_URL, $url); curl_setopt($session, CURLOPT_HTTPGET, 1); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content -Type: application/xml')); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); if(ereg("^(https)",$url)) curl_setopt($session,CURLOPT_SSL_VERIFYPEER,false); $response = curl_exec($session); curl_close($session); $product_xml = new SimpleXMLElement($response); echo $product_xml->title; echo $product_xml->variants->variant->{'inventory-quantity'}; ?> I'm having trouble with the first part. $API_KEY, $SECRET and $TOKEN I know, but $STORE_URL and $PRODUCT_ID are giving me trouble. Although it seems logical the $STORE_URL should be the url of the store I'm creating the app (plugin) for, because the API should know where to get information from. But I'm hesitant about filling it in because the app is supposed to be public. I'm my mind the URL should be variable to the url of the shop that downloads the app. I can't find any answer to this. As for $PRODUCT_ID, I don't even know what that could be. I'm not given any product id alongside the API key. Products in the shopify store each have their own ID, but to me it seems the API shouldn't bind itself to one product. I'm not completely a-technical, but I'm having trouble wrapping my head around this one. Especially because of lack of documentation. Shopify does provide some libraries, but again, the documentation is not sufficient for someone like me. Can somebody shine a light for me? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.