• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Android use okhttp3 to call wordpress REST API

I wrote a very simple and small android application to show a WordPress site in this application, I have a customized login form and after successe login, I want to bypass login to this site so at first, I called login rest API and then show shop page of the site. when I call login REST API by POSTMAN everything is OK but when I want to login bye application I have this error:"No route was found matching the URL and request method"

protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_main);     declareViews();     initlizize();     set();     //showDialog();     myWebView.setWebViewClient(new myWebWiewClient());        WebSettings webSettings = myWebView.getSettings();     webSettings.setJavaScriptEnabled(true);     webSettings.setSupportZoom(true);     webSettings.setBuiltInZoomControls(true);     webSettings.setDisplayZoomControls(true);     myWebView.getSettings().setDomStorageEnabled(true);     myWebView.getSettings().setDatabaseEnabled(true);     //myWebView.addJavascriptInterface(myJSInterface, "JSInterface");     myWebView.getSettings().setMinimumFontSize(1);     myWebView.getSettings().setMinimumLogicalFontSize(1);     myWebView.setWebViewClient(new myWebWiewClient());     myWebView.loadUrl("http://teslapart.ir/wp-json/mahan/login");     //hideDialog();  }  public class myWebWiewClient extends WebViewClient {      @SuppressWarnings("deprecation") // From API 21 we should use another overload     @Override     public WebResourceResponse shouldInterceptRequest(WebView view, String url) {         return handleRequest(url);     }      @TargetApi(Build.VERSION_CODES.LOLLIPOP)     @Override     public WebResourceResponse shouldInterceptRequest(@NonNull WebView view, @NonNull WebResourceRequest request) {         return handleRequest(request.getUrl().toString());     }     private WebResourceResponse handleRequest(String url) {         final MediaType mediaType = MediaType.parse("application/json; charset=utf-8");         RequestBody body = RequestBody.create(mediaType, "{
"username":"1001",
"password":"1001"
}");         try {             final Call call = okHttpClient.newCall(new Request.Builder()                     .url("http://teslapart.ir/wp-json/mahan/login")                     .post(body)                     .addHeader("Content-Type", "application/json")                     .addHeader("User-Agent", "PostmanRuntime/7.19.0")                     .addHeader("Accept", "*/*")                     .addHeader("Cache-Control", "no-cache")                     .addHeader("Postman-Token", "5ebadba7-259a-493a-90b3-3f3827315e1c,2f2bff68-9fc8-4af0-ab00-a383d0270ef9")                     .addHeader("Accept-Encoding", "gzip, deflate")                     .addHeader("Cookie", "PHPSESSID=178mqft2dc6tuff3htkuh3hg82; wordpress_logged_in_060b695cba4d91b20b4f69ce1b780515=1001%7C1574693262%7CMszwPvEEYqtvIhD2Lk3BWCrBmphJk050snmJjtkq9V2%7Ce606b43c875b33aa8f1b59a93ec085046bc35dea025a952d3237a0ef9e563df5")                     .addHeader("Referer", "http://teslapart.ir/wp-admin/")                     .addHeader("Connection", "keep-alive")                     .addHeader("cache-control", "no-cache")                     .build()             );              final Response response = call.execute();             updateScreenTitle(Integer.toString(response.code()));              return new WebResourceResponse(                     response.header("content-type", "text/plain"), // You can set something other as default content-type                     response.header("content-encoding", "utf-8"),  // Again, you can set another encoding as default                     response.body().byteStream()             );         } catch (Exception e) {             // TODO: Figure out how to show a custom error screen when we fail             return null;         }     }  } 
Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]