2016-12-16 46 views
0

我已經看過大多數有關他們的prestashop.Some的問題是說,有在這個環節沒有API的prestashop.look如何將android應用程序連接到PrestaShop?

http://online.fastchef.in/api/customers/12?output_format=JSON

它給結果JSON form.only事是解析這個form.but仍m到處錯誤 我的代碼:MainActivity

Retrofit retrofit = new Retrofit.Builder() 
        .baseUrl(API_BASE_URL)  
        .addConverterFactory(GsonConverterFactory.create(gson)) 
        .build(); 
int id=Integer.parseInt(mEditText.getText().toString()); 


PrestaShopClient client =retrofit.create(PrestaShopClient.class); 
Call<Customer> hj=client.getCustomer(id); 
hj.enqueue(new Callback<Customer>() { 

     @Override 
     public void onResponse(Call<Customer> call, Response<Customer> response) { 

       int status = response.code(); 
       Customer customer = response.body(); 
       mTextView.setText(customer.getFirstname()); 
                  } 

    @Override 
     public void onFailure(Call<Customer> call, Throwable t) { 

                 } 
          }); 

PrestaShopCLient:

public interface PrestaShopClient { 

@GET("customers/{id}?output_format=JSON") 
Call<Customer> getCustomer(@Path("id") int id); 

}

幫我傢伙...這個問題我花了一天半次(

回答

0

我們建議您創建一個單獨的Web服務,將與您的Android應用,並取溝通和JSON數據傳遞格式。

Web服務是指存在於PrestaShop安裝中的PHP文件。它根據收到的請求執行操作,並返回JSON格式的數據,這些數據可以由您的Android應用程序針對各自的功能進一步解碼。

您可以從下面的鏈接

Prestashop Android App

下載web服務
相關問題