程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了BasicNetwork.performRequest:带有 Volley 库的 newsapi.org 的意外响应代码 403大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决BasicNetwork.performrequest:带有 Volley 库的 newsapi.org 的意外响应代码 403?

开发过程中遇到BasicNetwork.performrequest:带有 Volley 库的 newsapi.org 的意外响应代码 403的问题如何解决?下面主要结合日常开发的经验,给出你关于BasicNetwork.performrequest:带有 Volley 库的 newsapi.org 的意外响应代码 403的解决方法建议,希望对你解决BasicNetwork.performrequest:带有 Volley 库的 newsapi.org 的意外响应代码 403有所启发或帮助;

这里有一个简单的代码来返回任何数据,API 网站有 JsON 对象文件。我尝试了很多不同的东西仍然不起作用。然而,它完美地工作,让我们说https://www.metaweather.com/api/。我导入了库和互联网权限,当我吐槽错误时,它说 Volley.AuthFailure。任何帮助将不胜感激谢谢

getBtn.setonClickListener(new VIEw.onClickListener() {

        @OverrIDe
        public voID onClick(View view) {


            requestQueue requestQueue;

            // Instantiate the cache
            Cache cache = new diskBasedCache(getCacheDir(),1024 * 1024); // 1MB cap

            // Set up the network to use httpURLConnection as the http clIEnt.
            Network network = new BasicNetwork(new HurlStack());

            // Instantiate the requestQueue with the cache and network.
            requestQueue = new requestQueue(cache,network);

            // Start the queue
            requestQueue.start();

            String url ="https://newsAPI.org/v2/top-headlines?country=us&APIKey=ba4529c51872486fb59a7a98de934d54";

            // Formulate the request and handle the response.
            Stringrequest Stringrequest = new Stringrequest(request.Method.GET,url,new Response.Listener<String>() {
                        @OverrIDe
                        public voID onResponse(String responsE) {
                            // Do something with the response
                            Toast.makeText(MainActivity.this,"YAHOOOOO success!",Toast.LENGTH_SHORT).show();
                        }
                    },new Response.ErrorListener() {
                        @OverrIDe
                        public voID onErrorResponse(VolleyError error) {
                            // Handle error
                            Toast.makeText(MainActivity.this,"Error occurred" + error,Toast.LENGTH_SHORT).show();
                        }
                    });

            // Add the request to the requestQueue.
            requestQueue.add(Stringrequest);

        }
    });

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的BasicNetwork.performRequest:带有 Volley 库的 newsapi.org 的意外响应代码 403全部内容,希望文章能够帮你解决BasicNetwork.performRequest:带有 Volley 库的 newsapi.org 的意外响应代码 403所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:403库的