
Hi Sridhar, Please find the sample below:
CANVAS APPLICATION USING CONNECTED APP
1. To set the end point URL we should configure the Remote Site Settings.
Go to Setup Security Controls Remote site Settings New Remote Site.
2. Create Controller class to call the Wal-Mart API (WalmartController)
Go to Setup Develop Apex Classes New
global class WalmartController{
public Integer ItemId{get;set;}
public List<Items> dr{get;set;}
public WalmartController(){
}
public void requestM(){
String url = 'http://api.walmartlabs.com/v1/feeds/specialbuy?apikey=YourApiId&categoryId=3944';
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
Http http = new Http();
HttpResponse res = http.send(req);
String responseBody = res.getBody();
system.debug('statuscode: ' + res.getStatusCode());
//system.debug('Response : ' + responseBody);
ResCls resItem = (ResCls)JSON.deserialize(responseBody, ResCls.class);
system.debug('Response after deserialization: ' + resItem);
system.debug('Response Items: ' + resItem.items);
List<Items> rl = resItem.items;
dr = new List<Items>();
for(Items it:rl){
system.debug('Item Name: ' + it);
ItemId = it.ItemId;
system.debug('ItemId: ' + it.ItemId);
dr.add(it);
}
system.debug('List: ' + dr);
}
public class ResCls{
List<Items> items;
}
public class Items{
public Integer ItemId{get;set;}
public Integer ParentItemId{get;set;}
public String Name{get;set;}
public Double SalePrice{get;set;}
public String Upc{get;set;}
public String CategoryPath{get;set;}
public Boolean AvailableOnline{get;set;}
public String ShortDescription{get;set;}
public String LongDescription{get;set;}
public String BrandName{get;set;}
public String ThumbnailImage{get;set;}
public String LargeImage{get;set;}
public String ProductTrackingUrl{get;set;}
public Boolean FreeShipping{get;set;}
public Boolean NinetySevenCentShipping{get;set;}
public Double StandardShipRate{get;set;}
public Double TwoThreeDayShippingRate{get;set;}
public Double OvernightShippingRate{get;set;}
public String Size{get;set;}
public String Color{get;set;}
public Boolean Marketplace{get;set;}
public Boolean ShipToStore{get;set;}
public Boolean FreeShipToStore{get;set;}
public String ModelNumber{get;set;}
public String SellerInfo{get;set;}
public String ProductUrl{get;set;}
public List<Integer> Variants{get;set;}
public List<String> Shelves{get;set;}
public String CustomerRating{get;set;}
public String CustomerRatingImage{get;set;}
public Integer NumReviews{get;set;}
public String CategoryNode{get;set;}
public Boolean isRollBack{get;set;}
public Boolean isSpecialBuy{get;set;}
public String Isbn{get;set;}
public Boolean Bundle{get;set;}
public Boolean Clearance{get;set;}
public Boolean PreOrder{get;set;}
public String PreOrderShipsOn{get;set;}
public String Stoc{get;set;}
public Boolean Freight{get;set;}
public Long DealEndTime{get;set;}
public Long DealStartTime{get;set;}
public String Gender{get;set;}
public String Age{get;set;}
}}
3. Create VisualForce Page to disply Item details.
Go to Setup Develop Pages New Name (CanWalEx) click on Save
<apex:page Controller="WalmartController" action="{!requestM}" sidebar="false" showHeader="false">
<apex:pageBlock>
<apex:pageblockSection >
<apex:pageblockTable value="{!dr}" var="dd">
<apex:column headerValue="Item id"><apex:outputText value="{!dd.ItemId}"/></apex:column>
<apex:column headerValue="Name"><apex:outputText value="{!dd.name}"/></apex:column>
<apex:column headerValue="upc"><apex:outputText value="{!dd.Upc}"/></apex:column>
<apex:column headerValue="SalePrice"><apex:outputText value="{!dd.SalePrice}"/></apex:column>
<apex:column headerValue="AvailableOnline"><apex:outputText value="{!dd.AvailableOnline}"/></apex:column>
<apex:column headerValue="BrandName"><apex:outputText value="{!dd.BrandName}"/></apex:column>
</apex:pageblockTable>
</apex:pageblockSection></apex:pageBlock></apex:page>
Give Preview to this page and Copy the URL
4. Create the Canvas Application.
Go to setupàCreateàAppsàConnected AppsàNew
In Basic Information section
Give the Application name, API Name and Contact Email.
API (Enable Outh Settings)àEnable outh settings
Give the Callback URL (Domain name of the organization)
Select the Outh Scope Settings
Give the Canvas App Settings
Enable Force.com Canvas
Give the Canvas app URL
Use the copied CanWalEx VF Page preview page URL and mention as a Canvas app URL.
Access Method as Single Request (POST).
Add the Chatter Tab in Locations.
Click on the Save.
5. Click on the Chatter Tab
Sidebar clicks on the Application name (WalmartApp).
The above is the example pattern for integrating waltmat products with salesforce.Follow the same steps to integrate quickbook with salesforce.
After generating the consumer key and consumer secret credentials please check with the below document which helps you to know where to use them exactly.http://cloudcatamaran.com/2014/01/quickbooks-integration-with-salesforce-part-2/I kindly request you to please close this thread by marking it as solved if it helps.Best Regards,Nagendra.P
1 resposta