找不到api api usng instagram帖子链接的文件异常

问题描述

我正在通过instagram帖子链接制作instagram帖子下载器应用程序,但我正面临FileNotFoundException()。我尝试了许多代码来实现这一点。但是我每次都失败了。我在下面提到代码。如果有人知道解决方案,请帮助我。


InstagramPostDownloadActivity.java

binding.instaDownload.setOnClickListener(view -> new InstaUrl().execute(binding.instaEdittext.getText().toString()));


  private class InstaUrl extends AsyncTask<String,Void,Void> {
        private String response;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected Void doInBackground(String... arg0) {

            response = reqId(arg0[0]);

            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);

        }

        private String reqId(String input) {

            String oId = "";

            String jsonPly = makeServiceCall("https://api.instagram.com/oembed/?url=" + input);

            if (jsonPly != null) {
                try {
                    JSONObject _plyJsonObj = new JSONObject(jsonPly);

                    oId = _plyJsonObj.getString("media_id");

                } catch (final JSONException e) {
                   // Toast.makeText(inContext,e.getMessage(),Toast.LENGTH_SHORT).show();
                }
            }

            return oId;
        }

    }

private String makeServiceCall(String reqUrl) {
        String response = null;
        try {
            URL url = new URL(reqUrl);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setConnectTimeout(20000);
            InputStream in = new BufferedInputStream(conn.getInputStream());
            response = convertStreamToString(in);
        } catch (MalformedURLException e) {
            Log.e("TAG","MalformedURLException: " + e.getMessage());
        } catch (ProtocolException e) {
            Log.e("TAG","ProtocolException: " + e.getMessage());
        } catch (IOException e) {
            Log.e("TAG","IOException: " + e.getMessage());
        } catch (Exception e) {
            Log.e("TAG","Exception: " + e.getMessage());
        }
        return response;
    }
    private String convertStreamToString(InputStream is) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();

        String line;
        try {
            while ((line = reader.readLine()) != null) {
                sb.append(line).append('\n');
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }

错误是

java.io.FileNotFoundException: https://api.instagram.com/oembed/?url=https://www.instagram.com/p/CG4lDJupCGr/?igshid=1hecl18q7riwj

请帮助我...谢谢

解决方法

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

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

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