phpish / shopify_app-skeleton

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

Getting Notice #25

Open reachtokish opened 7 years ago

reachtokish commented 7 years ago

Undefined index: signature in C:\xampp\htdocs\php-shop-app\new_prj\vendor\phpish\shopify\shopify.php on line 14

myjanky commented 7 years ago

Need more info. Can you post your apache error logs?

reachtokish commented 7 years ago

Getting exactly the following issues

myjanky commented 7 years ago

you can not use localhost...

Also, Never post screenshots like this. I have your hmac and other personal tidbits are displayed for all to see.

reachtokish commented 7 years ago

ok thanks for your kind information.

I will use heroku . let see if the problem will solved

Thanks

@myjanky

reachtokish commented 7 years ago

Now I'm using heroku and getting an error

Invalid Request! Request or redirect did not come from Shopify

Don't know what to do. can you pls tell me what is going wrong here

Thanks

myjanky commented 7 years ago

What scopes are you using and what are you trying to do? @reachtokish I can not help with these error messages as they are the generic ones the app_skeleton displays.

The best thing to do is to read and understand how each part works down to its basics. The first thing I would do is understand Oauth. many issues can be solved once you have Oauth working and understand how it works.

https://aaronparecki.com/2012/07/29/2/oauth2-simplified

reachtokish commented 7 years ago

Hi thanks for your quick reply. Basically I'm a shopify developer and I want to develop a shopify app by PHP as I don't know Ruby on Rails. So want to develop a Shopify app

Thanks

myjanky commented 7 years ago

Again, I can not help you with out having more details of the error. Invalid request could be caused by a number of things.

reachtokish commented 7 years ago

Hi, Thanks @myjanky for your quick response

I have checked some other issues but can't find a solution. Getting error saying 'Invalid Request! Request or redirect did not come from Shopify' which I have post before

This is my developer dashboard screenshot

fireshot capture 3 - edit app settings for myapp - shopify _ - https___app shopify com_services_pa

This is my error which I'm getting

fireshot capture 4 - - https___main-shop-app herokuapp com_oauth php_hmac 0b164d58c70725dc40c81b

This is my oauth.php code

    session_start();

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

    require __DIR__.'/conf.php';

    # Guard: http://docs.shopify.com/api/authentication/oauth#verification
    shopify\is_valid_request($_GET, SHOPIFY_APP_SHARED_SECRET) or die('Invalid Request! Request or redirect did not come from Shopify');

    # Step 2: http://docs.shopify.com/api/authentication/oauth#asking-for-permission
    if (!isset($_GET['code']))
    {
        $permission_url = shopify\authorization_url($_GET['shop'], SHOPIFY_APP_API_KEY, array('read_content', 'write_content', 'read_themes', 'write_themes', 'read_products', 'write_products', 'read_customers', 'write_customers', 'read_orders', 'write_orders', 'read_script_tags', 'write_script_tags', 'read_fulfillments', 'write_fulfillments', 'read_shipping', 'write_shipping'));
        die("<script> top.location.href='$permission_url'</script>");
    }

    # Step 3: http://docs.shopify.com/api/authentication/oauth#confirming-installation
    try
    {
        # shopify\access_token can throw an exception
        $oauth_token = shopify\access_token($_GET['shop'], SHOPIFY_APP_API_KEY, SHOPIFY_APP_SHARED_SECRET, $_GET['code']);

        $_SESSION['oauth_token'] = $oauth_token;
        $_SESSION['shop'] = $_GET['shop'];

        echo 'App Successfully Installed!';
    }
    catch (shopify\ApiException $e)
    {
        # HTTP status code was >= 400 or response contained the key 'errors'
        echo $e;
        print_R($e->getRequest());
        print_R($e->getResponse());
    }
    catch (shopify\CurlException $e)
    {
        # cURL error
        echo $e;
        print_R($e->getRequest());
        print_R($e->getResponse());
    }

This is my conf.php code

    define('SHOPIFY_APP_API_KEY', '65394bcb4a6a92f4f8c5220a8e5b7295');
    define('SHOPIFY_APP_SHARED_SECRET', '809b15cd52b228da3f251b581706209b');

This is my install.php code

    # install.php?shop=example-shop.myshopify.com

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

    require __DIR__.'/conf.php';

    # Guard
    isset($_GET['shop']) or die ('Query parameter "shop" missing.');
    preg_match('/^[a-zA-Z0-9\-]+.myshopify.com$/', $_GET['shop']) or die('Invalid myshopify.com store URL.');

    $install_url = shopify\install_url($_GET['shop'], SHOPIFY_APP_API_KEY);
    echo "<script> top.location.href='$install_url'</script>";

This is my app url https://apps.shopify.com/myapp-8

Please help me I'm stuck for this issue

Thanks

myjanky commented 7 years ago

look https://github.com/phpish/shopify_app-skeleton/issues/22 and add your redirect url to your conf.php as REDIRECT_URL then use that var to fix the $permision_url as described here.

https://github.com/phpish/shopify_app-skeleton/issues/22

reachtokish commented 7 years ago

Hi, Thanks for your kind information. Basically I had read this #22 issue before. I was not very much sure about that issue. I will definitely follow your suggestion. Btw can you pls tell me settings of my development dashboard is ok or not?

Thanks @myjanky

myjanky commented 7 years ago

settings look ok.

reachtokish commented 7 years ago

Thanks @myjanky

reachtokish commented 7 years ago

@myjanky are you god or something else like that. App install successfully. I'm just excited. Finding this solution for a month. Really I'm very much thankfull to you for your kind information and helping me

Thanks a lot @myjanky

One thing can you tell me that now after installation or clicking on my app from dashboard the app is redirecting me to heroku URL . So I want the app to my Shopify dashboard like other apps. Is this possible?

Thanks @myjanky

myjanky commented 7 years ago

Yes, check this out for a theme and some back end logic http://seaff.microapps.com/ then copy the contents from the url below into app file (aka get_products.php). https://help.shopify.com/api/sdks/embedded-app-sdk/initialization

has a forceRedirect boolean to get you where you need to be.

reachtokish commented 7 years ago

OK let me check

Thanks @myjanky

reachtokish commented 7 years ago

Yes it works for me

Thanks a lot @myjanky :)

myjanky commented 7 years ago

That is great. You're welcome!

reachtokish commented 7 years ago

Hi @myjanky Thanks for your previous help

Can you pls tell me that how can I run shopify on my local machine? That means I dont need to open shopify dashboard.

Basically I told you that I am a shopify liquid template developer and almost every time I have to work with css, HTML, jquery like stuffs and every time I have to open dahboard editor and edit my theme css, HTML. Is there any way that I can do all shopify in my local machine and after doing all the work then I can upload the theme to the shopify dashboard. Is it possible?

I know there is a way using theme kit of shopify but not so much sure that this will work or not.

This question is not related to this repo but I really want to know this

Please help me with this

Thanks

myjanky commented 7 years ago

I use beanstalkapp.com for version management. It lets you use GIT to push changes to beanstalkapp and then you can deploy using the apps settings. Now, you would not be able to run shopify locally but at least edit the files offline locally in your own editor (or in beanstalkapp editor).

If you use beanstalkapp then any edits in the shopify editor would not be saved in beanstalkapp. (one way pull).

reachtokish commented 7 years ago

Thanks a lot @myjanky