phpish / shopify_app-skeleton

Skeleton Shopify App project using phpish/shopify
94 stars 41 forks source link

how can i create a CronJob ? #39

Open kimannou opened 7 years ago

kimannou commented 7 years ago

Hi ! how can i create a CronJob ? i nfact i changed the get_products.php so it became like this : `session_start();

require __DIR__.'/vendor/autoload.php';
use phpish\shopify;

require __DIR__.'/conf.php';
$shopify = shopify\client(
    'myshop.myshopify.com',
    SHOPIFY_APP_API_KEY, 
    'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
try
{
    # Making an API request can throw an exception
    $products = $shopify('GET /admin/products.json', array('published_status'=>'published'));
    echo '<pre>';print_r($products);echo '</pre>';die;
}`

in fact this is working perfectly when i call it from an url in browser and it show the perfect result, but when i execute this code in a commmand line using : php get_products.php it shows this error : ` ~/www/shopify $ php get_products.php phpish\shopify\CurlException: [7] in /home/cmsservixi/www/shopify/get_products.php on line 19Array ( [method] => GET [uri] => https://myshop.myshopify.com/admin/products.json [query] => Array ( [published_status] => published )

[headers] => Array
    (
        [X-Shopify-Access-Token] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        [content-type] => application/json; charset=utf-8
    )

[payload] =>

) Array ( )`

myjanky commented 7 years ago

whats on line 19 of get_products.php

kimannou commented 7 years ago

there is the GET request : $products = $shopify('GET /admin/products.json', array('published_status'=>'published'));

myjanky commented 7 years ago

curl exception 7 means it could not connect to the host.

The URI seems to be wrong but you may have done that for privacy concerns. What does the URI take you to?

kimannou commented 7 years ago

in fact the shop exists : https://cmsplus-dev.myshopify.com as i told you when i execute get_products.php with an url : https://cmsservizi.net/shopify/get_products.php as you will see it works perfectly and shows the list of products... the same file in that url (get_products.php), when i execute it in the command line it gives me the error that i mentionned

myjanky commented 7 years ago

can you try to curl to your myshopify url from the command line?

kimannou commented 7 years ago

I figured something, i think it's a problem in my remote server. because when i try to execute https://cmsservizi.net/shopify/get_products.php in command line from my localhost it works perfectrly, as well as "curl" command, works in my localhost and not working in my remote server. Do you have any idea what is the configuration that i have to do in the remote server so i can make it work ? thank you in advance

myjanky commented 7 years ago

What is hosting your remote server? can you tell what version of php and LAMP etc...

myjanky commented 7 years ago

to be honest I would use the ohShopify php library instead of this one. Have you updated the HMAC issue on this library?

kimannou commented 7 years ago

Hi ! it appear that the problem is in the server network, even when i execute : $ curl google.com i get the error : curl: (7) Couldn't connect to server i contact the hosting company and i'll return to you with also the configuration of the server. Thanks