Facebook“无法从URL检索数据” [英] facebook "could not retrieve data from URL"

查看:228
本文介绍了Facebook“无法从URL检索数据”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用图形API调用Facebook时,我收到以下错误。我知道我的回调网址很好,因为当我在facebook调试器中测试它时,它看起来很好。我也在使用Google App Engine,我真的认为这个错误可能与async呼叫从Facebook返回到我的GAE应用程序,而线程访问的线程正在等待回复。

I'm getting the below error when attempting to make a graph api call to facebook. I know my callback url is fine because when I test it in the facebook debugger, it views the page just fine. I'm also using Google App Engine and I'm really thinking this error might have something to do with the async call coming back from facebook to my GAE app while the thread making the URL Fetch is stil active waiting for the reply.

错误:

{"error":{"type":"Exception","message":"Could not retrieve data from URL."}} 

我的代码进行调用:

            URL url = new URL("https://graph.facebook.com/me/");
            HttpURLConnection connection = (HttpURLConnection) url
                    .openConnection();
            connection.setDoOutput(true);
            connection.setRequestMethod("POST");
                    connection.setConnectTimeout(30000);

            OutputStreamWriter writer = new OutputStreamWriter(
                    connection.getOutputStream());
            writer.write("access_token=" + access_token + "&activity=" + ogpUrl);
            writer.close();

            if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                log.info("GraphApiHelper: success stream");
            } else {
                log.severe("GraphApiHelper: error stream: "
                        + connection.getResponseMessage());
            }

任何想法可能导致这种情况,或者如果GAE在这些类型的URL抓取?如果导致问题,我还会增加连接超时。不知道它是否相关,但我认为这是一个完全普遍的错误,从facebook linter,所以这可能意味着一个问题的呼叫本身。

Any thoughts what could be causing this or if GAE behaves strangely on these type of URL Fetches? Iv'e also increased the timeout on the connection in case that was causing the issue. Not sure if it's relevant or not either too, but I think this is a completely generic error from the facebook linter so it could mean a problem with the call itself.

另外我可以看到Facebook linter在日志中对我的GAE应用程序进行回调,我没有看到任何错误。

Additionally I can see the Facebook linter making the callback to my GAE app in the logs and I'm not seeing any errors in that response.

编辑:好的,这显然是一个超时的问题。我注意到,当一个新的GAE实例没有在facebook linter回调中被激活时,它正常工作。当新的GAE实例被激活时,它需要大约50秒左右。我在10秒内从Facebook收到错误。那么在这段时间里有什么是超时的,无论是facebook linter还是GAE URL Fetch。

Ok this is clearly a timing out issue. I'm noticing that when a new GAE instance isn't fired up on the facebook linter callback, that it works correctly. When a new GAE instance is fired up, it takes upwards of 50 seconds or so. I get the error back from Facebook within 10 seconds. So something is timing out in that period whether it's the facebook linter or GAE URL Fetch.

推荐答案

也可能有一些并发问题。
看到这个,对我来说很好。
从Rails Heroku的Facebook Open Graph

There might be some concurrency issue as well. See this, it worked well for me. Facebook Open Graph from Rails Heroku

这篇关于Facebook“无法从URL检索数据”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆