SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict Procode's Avatar
    Join Date
    Dec 2006
    Location
    New York
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP and Shopify API Dilema, Please help!

    Hello!

    I am currently creating an app for shopify, and I am using https://github.com/cmcdonaldca/ohShopify.php as the php API which seems to be what everyone uses. However I ran into a few problems.

    My code:

    Code PHP:
    <?php
    include('shopify.php');
     
    $api_key = 'xxxxxxxxxxxxxxxx;
    $secret = 'xxxxxxxxxxxxxxxxx';
     
    $sc = new ShopifyClient($_GET['shop'], $_GET['t'], $api_key, $secret);
     
    try
        {
            // Get all products
            $products = $sc->call('GET', '/admin/products.json', array('published_status'=>'any'));
     
        }
        catch (ShopifyApiException $e)
        {
            /* 
             $e->getMethod() -> http method (GET, POST, PUT, DELETE)
             $e->getPath() -> path of failing request
             $e->getResponseHeaders() -> actually response headers from failing request
             $e->getResponse() -> curl response object
             $e->getParams() -> optional data that may have been passed that caused the failure
     
            */
        }
        catch (ShopifyCurlException $e)
        {
            // $e->getMessage() returns value of curl_errno() and $e->getCode() returns value of curl_ error()
        }
    echo var_dump($products);
    ?>

    Now the problem is that the var_dump results come out NULL, however I do have products in my test store.

    This page loads right after the authorization so the $_GET variables are there and filled.

    If you can help, I would be forever grateful.

  2. #2
    SitePoint Addict kduv's Avatar
    Join Date
    May 2012
    Location
    Atlanta, GA
    Posts
    244
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    I would change the following two blocks just so you can see what the error is:
    PHP Code:
    catch (ShopifyApiException $e)
        {
             echo 
    $e->getResponse();
        }
        catch (
    ShopifyCurlException $e)
        {
            echo 
    $e->getMessage();
        } 

  3. #3
    SitePoint Addict Procode's Avatar
    Join Date
    Dec 2006
    Location
    New York
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did that and I see the error:

    "SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failedNULL"

    Now, does that mean that their SSL is no good? Because I am on my localhost and I don't have any certificates. Also how could I fix this issue? Many websites use their API with no problem and I don't think something would be wrong with a company that big.

    Thanks!

  4. #4
    SitePoint Addict kduv's Avatar
    Join Date
    May 2012
    Location
    Atlanta, GA
    Posts
    244
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    It sounds like an issue with the certificate on the server you're trying to access. It could be an invalid certificate, or it could be self-signed. Where is your shop hosted?b Is it on your server? Are you using a self signed SSL certificate? If so, you can open shopify.php and change line 105

    From:
    PHP Code:
    curl_setopt($chCURLOPT_SSL_VERIFYPEERtrue); 
    To
    PHP Code:
    curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse); 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •