我在我的项目中使用Picasso库来加载图像和缓存它们.它没有任何问题,效果很好.但是,当我尝试使用OkHttp库与我的服务器(JSON通信)进行数据通信时,Picasso会抛出异常.
我使用以下罐子:okhttp-2.0.0-RC2,okio-1.0.0,picasso-2.2.0.当我添加这些罐子后运行我的项目时,它崩溃了以下内容:
06-12 11:13:15.824: E/dalvikvm(12105): Could not find class 'com.squareup.okhttp.HttpResponseCache', referenced from method com.squareup.picasso.OkHttpDownloader.<init>
Run Code Online (Sandbox Code Playgroud)
我添加了okhttp只是为了使用以下方法:
public static String executeHttpGet(String urlStr) {
Response response = null;
String result = "";
OkHttpClient client = new OkHttpClient();
try {
Request request = new Request.Builder().url(urlStr).build();
response = client.newCall(request).execute();
result = response.body().string();
} catch (Exception ex) {
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
上面的代码没有任何问题.然而,使用Picasso库并且用于完美工作的代码开始抛出以下例外:
06-12 11:19:49.307: E/AndroidRuntime(13036): FATAL EXCEPTION: main
06-12 11:19:49.307: E/AndroidRuntime(13036): java.lang.NoClassDefFoundError: com.squareup.okhttp.HttpResponseCache
06-12 11:19:49.307: E/AndroidRuntime(13036): at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:74)
06-12 11:19:49.307: E/AndroidRuntime(13036): at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:51)
06-12 11:19:49.307: …Run Code Online (Sandbox Code Playgroud) 我有一个Android应用程序,可为用户提供其Facebook帐户使用它的功能。为此,我集成了Facebook登录。但是,我对Facebook的用户注册感到困惑。
用户登录后,Facebook将提供userId,电子邮件和访问令牌。我可以使用它们在后端为用户创建一个帐户。让我们演示一下场景:
用户至上
1- User logged-in by Facebook.
2- The email is checked by server and returns no such user
3- An account is created by the information from Facebook
4- The user keeps using the app with this account.
Run Code Online (Sandbox Code Playgroud)
用户再次来
1- User logged-in by Facebook.
2- The email is checked by the server and returns that there exists a user.
Run Code Online (Sandbox Code Playgroud)
在这里,这里是问题:
1-服务器如何信任真正来自Facebook的请求,以便服务器可以响应应用程序“他可以登录”?可以肯定,我是否也应该通过在服务器端连接到Facebook来验证访问令牌?
2-如果没有,如何以一种非常安全的方式使用Facebook登录名来注册用户?
我的服务器上有一个名为"MyFile.doc"的文件,同一个实例中有一个jsp.在jsp中有一个重定向,如:response.sendRedirect("MyFile.doc");. 当用户访问我的jsp文件时,我想将该文件命名为"MyFile_XYZT.doc".简而言之,应该使用动态创建的ID下载它.
我搜索并发现了一些关于Content-Disposition方法的内容.
有任何想法吗 ?