How to use App Bridge with PHP base using CI?

dishant
New Member
4 0 0

Hi

I have checked New app tutorial but sample code in Node and React JS. But Our existing app in CI base with older version. So, we want to convert into new app bridge version.  Is there any tutorial in PHP base?

If have any tutorial  related to PHP then let us provide. So, we can convert into new app bridge.

 

Thanks

Replies 11 (11)

Michal17
Shopify Partner
835 73 175

Hi @dishant 

Hope you're having a great day!

There is no official PHP tutorial from Shopify like the one done in Node and React. But there are tutorials from community developers. 

Useful resource:

dishant
New Member
4 0 0

Hi,

Thanks for providing usefull resources. I will go with this resources and if need any help then I will contact you.

 

Thanks

dishant
New Member
4 0 0

Hello,

I got Basic shopify api library. https://github.com/osiset/Basic-Shopify-API. So, want to know this library also implemented with new app bridge ?

 

Thanks

sv2109
Visitor
2 0 0

Hi, take a look at this Youtube channel it contains many videos about Shopify development using PHP
https://www.youtube.com/watch?v=tX1E8fuesSE&list=PL-k7XHuPgeIsv2Q6QtJR__h3kkpmqNpH0

dishant
New Member
4 0 0

Hello,

I have followed steps which provided in Video. And my all already built app using same way. But I want to know what is different in New App bridge 2.0?

 

Thanks

dishantpatel100
Shopify Partner
2 0 0

Any Update on this?

Michal17
Shopify Partner
835 73 175

Hi @dishant again

But I want to know what is different in New App bridge 2.0?

As specified by Shopify:

Update May 2021: App Bridge 2.0 now available

Migrating to App Bridge 2.0 will ensure your app is aligned with the future of Shopify. This new release of App Bridge also includes a more streamlined interface for actions and an improved architecture for tree-shaking.

As browsers apply stricter restrictions on third-party cookie tracking, apps require an alternative way to handle authentication. App Bridge 2.0 paves the way for apps to migrate from third-party cookie authentication to session tokens.

Useful resources:

If you found this comment useful, hit the 'Like' and 'Accepted solution' buttons.

dishantpatel100
Shopify Partner
2 0 0

Hi,

We have read your new app bridge 2.0 version-related articles & flowchart/diagram.

We have created the app in the same way as per the flowchart/diagram. We have created an app in the partner Account and added the Client Key and Secret key in-app.

After that, the user installs the app using a shop URL then it redirects to the Authorize URL with the mentioned parameters like client_id, scope, and redirect_uri.

Afte the user installs the app, in Shopify admin they are redirected to redirect_uri, and we generate an access token using client_id, client_secret, and code which we got from redirect_uri as per your mention articles(https://shopify.dev/apps/auth/oauth). We already saved the token in our session which is mentioned as the session-based token.

Our app is ready & built as per your articles. However, we can't figure out the difference between App Bridge 2.0 version and the previous one.

We have already checked many Shopify libraries but don't have them in the PHP framework. You have implemented it in Rails. I would love that if you guys canprovide the new Shopify APP Bridge 2.0 version in PHP instead of Rails.

We have checked your forums, and found out that many users are facing the same issues. We have also checked the YouTube video https://www.youtube.com/watch?v=tX1E8fuesSE&list=PL-k7XHuPgeIsv2Q6QtJR__h3kkpmqNpH0 which is given by your team member in forums.

But we already developed our app the same way the video shows. We have also checked the GitHub Shopify API library https://github.com/osiset/Basic-Shopify-API, and they also provided the same logic we did in our app. So, I want to know what the difference is between APP bridge 1.0 and 2.0. And how can we easily convert our app bridge to App Bridge 2.0 in PHP?

Michal17
Shopify Partner
835 73 175

Hi @dishant 

Shopify App Bridge lets you embed your app directly inside the Shopify admin and Shopify POS, as well as customize Shopify UI elements outside of your app. App Bridge is a standalone vanilla JavaScript library, and also offers React component wrappers for some actions.

So App bridge has nothing to do with PHP libraries. In other words, no matter which PHP or Ruby library you use, you can always integrate App bridge into your project with a little Google search.

If you found this comment useful, hit the 'Like' and 'Accepted solution' buttons.

Michal17
Shopify Partner
835 73 175

Hi @dishant 

You're welcome. I'm happy to help.

Peter1983
Shopify Partner
17 0 0

This line detects when clicked after installed. 

if( $request->has('session') && $this->hashCheck($request) ){

  //Click the APP listing (after installed)

  //Your login logic

  //Or redirect to token generation again if necessary. 

}

else{

  //redirect to token generation

}


function hashCheck($request){
// Set variables for our request
$api_key = env('SHOPIFY_APP_API_KEY');
$shared_secret = env('SHOPIFY_APP_API_SECRET');

$params = $request->all(); // Retrieve all request parameters
$hmac = $request->get('hmac'); // Retrieve HMAC request parameter

$params = array_diff_key($params, array('hmac' => '')); // Remove hmac from params
ksort($params); // Sort params lexographically
$computed_hmac = hash_hmac('sha256', http_build_query($params), $shared_secret);

if (hash_equals($hmac, $computed_hmac)) return true;
return false;
}