- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的 Android 应用程序中使用 Facebook SDK。我需要的是获取用户的所有信息,包括姓名、电子邮件、生日、位置。但我所能得到的只是姓名和电子邮件。是否有获得生日和位置的权限?我也查看此链接,但如果不适合我 https://developers.facebook.com/docs/reference/api/user/ .
这是我获取信息的方式。
if(fb.isSessionValid()){
button.setImageResource(R.drawable.logout_button);
JSONObject obj = null;
URL img = null;
try {
String jsonUser = fb.request("me");
obj = Util.parseJson(jsonUser);
String id = obj.optString("id");
String name = obj.optString("name");
String bday = obj.optString("birthday");
String address = obj.optString("location");
String email = obj.optString("email");
((TextView) findViewById(R.id.txt)).setText("Welcome! "+name);
((TextView) findViewById(R.id.txtbday)).setText("Birthday: "+bday);
((TextView) findViewById(R.id.txtaddress)).setText("Address: "+address);
((TextView) findViewById(R.id.txtemail)).setText("Email: "+email);
img = new URL("http://graph.facebook.com/"+id+"/picture?type=normal");
Bitmap bmp = BitmapFactory.decodeStream(img.openConnection().getInputStream());
pic.setImageBitmap(bmp);
} catch (FacebookError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
this is my authorized
fb.authorize(MainActivity.this,new String[] {"email", "user_location", "user_birthday","publish_stream"}, new DialogListener() {
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), ""+e, Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
public void onError(DialogError e) {
// TODO Auto-generated method stub
//Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
}
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
Editor editor = sp.edit();
editor.putString("access_token", fb.getAccessToken());
editor.putLong("access_expires", fb.getAccessExpires());
editor.commit();
updateButtonImage();
}
public void onCancel() {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Cancel", Toast.LENGTH_SHORT).show();
}
});
}
}
日志是这么写的
11-14 14:05:40.399: E/Trace(1293): error opening trace file: No such file or directory (2)
11-14 14:05:41.699: D/dalvikvm(1293): GC_CONCURRENT freed 290K, 6% free 6173K/6535K, paused 71ms+76ms, total 201ms
11-14 14:05:42.509: I/Choreographer(1293): Skipped 82 frames! The application may be doing too much work on its main thread.
11-14 14:05:42.519: D/gralloc_goldfish(1293): Emulator without GPU emulation detected.
11-14 14:05:42.679: I/Choreographer(1293): Skipped 30 frames! The application may be doing too much work on its main thread.
我也从我的日志猫那里得到了这个
11-14 14:19:28.339: D/AndroidRuntime(1359): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
11-14 14:19:28.339: D/AndroidRuntime(1359): CheckJNI is ON
11-14 14:19:28.379: D/dalvikvm(1359): Trying to load lib libjavacore.so 0x0
11-14 14:19:28.389: D/dalvikvm(1359): Added shared lib libjavacore.so 0x0
11-14 14:19:28.409: D/dalvikvm(1359): Trying to load lib libnativehelper.so 0x0
11-14 14:19:28.409: D/dalvikvm(1359): Added shared lib libnativehelper.so 0x0
11-14 14:19:29.059: D/AndroidRuntime(1359): Calling main entry com.android.commands.pm.Pm
11-14 14:19:29.089: W/ActivityManager(146): No content provider found for permission revoke: file:///data/local/tmp/facebook.apk
11-14 14:19:29.119: W/ActivityManager(146): No content provider found for permission revoke: file:///data/local/tmp/facebook.apk
11-14 14:19:29.249: I/PackageManager(146): Removing non-system package:com.example.facebook
11-14 14:19:29.249: I/ActivityManager(146): Force stopping package com.example.facebook uid=10054
11-14 14:19:29.249: I/ActivityManager(146): Killing proc 1339:com.example.facebook/u0a54: force stop
11-14 14:19:29.249: W/ActivityManager(146): Force removing ActivityRecord{411f5b90 com.example.facebook/.MainActivity}: app died, no saved state
11-14 14:19:29.279: I/WindowState(146): WIN DEATH: Window{41263720 com.example.facebook/com.example.facebook.MainActivity paused=false}
11-14 14:19:29.429: I/Choreographer(263): Skipped 64 frames! The application may be doing too much work on its main thread.
11-14 14:19:29.429: I/PackageManager(146): Package com.example.facebook codePath changed from /data/app/com.example.facebook-1.apk to /data/app/com.example.facebook-2.apk; Retaining data and using new
11-14 14:19:29.479: W/InputMethodManagerService(146): Got RemoteException sending setActive(false) notification to pid 1339 uid 10054
11-14 14:19:29.559: I/PackageManager(146): Running dexopt on: com.example.facebook
11-14 14:19:30.549: D/dalvikvm(1369): DexOpt: load 142ms, verify+opt 469ms, 833796 bytes
11-14 14:19:30.569: W/PackageManager(146): Code path for pkg : com.example.facebook changing from /data/app/com.example.facebook-1.apk to /data/app/com.example.facebook-2.apk
11-14 14:19:30.569: W/PackageManager(146): Resource path for pkg : com.example.facebook changing from /data/app/com.example.facebook-1.apk to /data/app/com.example.facebook-2.apk
11-14 14:19:30.579: I/ActivityManager(146): Force stopping package com.example.facebook uid=10054
11-14 14:19:30.659: D/dalvikvm(146): GC_FOR_ALLOC freed 681K, 9% free 9626K/10567K, paused 81ms, total 81ms
11-14 14:19:30.759: D/PackageManager(146): New package installed in /data/app/com.example.facebook-2.apk
11-14 14:19:30.839: I/ActivityManager(146): Force stopping package com.example.facebook uid=10054
11-14 14:19:30.849: D/dalvikvm(263): WAIT_FOR_CONCURRENT_GC blocked 0ms
11-14 14:19:30.920: D/dalvikvm(330): WAIT_FOR_CONCURRENT_GC blocked 0ms
11-14 14:19:30.949: D/dalvikvm(263): GC_EXPLICIT freed 185K, 36% free 9272K/14471K, paused 7ms+14ms, total 92ms
11-14 14:19:31.009: D/dalvikvm(146): WAIT_FOR_CONCURRENT_GC blocked 0ms
11-14 14:19:31.059: I/InputReader(146): Reconfiguring input devices. changes=0x00000010
11-14 14:19:31.170: D/dalvikvm(146): GC_EXPLICIT freed 475K, 11% free 9461K/10567K, paused 38ms+10ms, total 163ms
11-14 14:19:31.189: D/PackageManager(146): generateServicesMap(android.accounts.AccountAuthenticator): 3 services unchanged
11-14 14:19:31.210: D/PackageManager(146): generateServicesMap(android.content.SyncAdapter): 5 services unchanged
11-14 14:19:31.219: D/BackupManagerService(146): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.facebook flg=0x8000010 (has extras) }
11-14 14:19:31.219: D/dalvikvm(330): GC_EXPLICIT freed 169K, 6% free 6320K/6663K, paused 5ms+6ms, total 293ms
11-14 14:19:31.259: D/PackageManager(146): generateServicesMap(android.accounts.AccountAuthenticator): 3 services unchanged
11-14 14:19:31.279: D/PackageManager(146): generateServicesMap(android.content.SyncAdapter): 5 services unchanged
11-14 14:19:31.299: D/BackupManagerService(146): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.facebook flg=0x8000010 (has extras) }
11-14 14:19:31.299: V/BackupManagerService(146): removePackageParticipantsLocked: uid=10054 #1
11-14 14:19:31.310: I/InputReader(146): Reconfiguring input devices. changes=0x00000010
11-14 14:19:31.429: V/BackupManagerService(146): addPackageParticipantsLocked: #1
11-14 14:19:31.699: I/Choreographer(263): Skipped 259 frames! The application may be doing too much work on its main thread.
11-14 14:19:31.909: I/Choreographer(263): Skipped 33 frames! The application may be doing too much work on its main thread.
11-14 14:19:32.179: D/dalvikvm(263): GC_CONCURRENT freed 1331K, 38% free 9017K/14471K, paused 29ms+9ms, total 116ms
11-14 14:19:32.179: D/dalvikvm(263): WAIT_FOR_CONCURRENT_GC blocked 62ms
11-14 14:19:32.179: D/dalvikvm(263): WAIT_FOR_CONCURRENT_GC blocked 80ms
11-14 14:19:32.439: D/dalvikvm(263): GC_CONCURRENT freed 415K, 34% free 9614K/14471K, paused 30ms+7ms, total 84ms
11-14 14:19:32.439: D/dalvikvm(263): WAIT_FOR_CONCURRENT_GC blocked 54ms
11-14 14:19:32.439: D/dalvikvm(263): WAIT_FOR_CONCURRENT_GC blocked 70ms
11-14 14:19:32.449: D/dalvikvm(263): WAIT_FOR_CONCURRENT_GC blocked 60ms
11-14 14:19:32.449: D/dalvikvm(263): WAIT_FOR_CONCURRENT_GC blocked 67ms
11-14 14:19:32.639: D/dalvikvm(263): GC_FOR_ALLOC freed 929K, 37% free 9199K/14471K, paused 41ms, total 47ms
11-14 14:19:32.649: I/dalvikvm-heap(263): Grow heap (frag case) to 10.257MB for 1286224-byte allocation
11-14 14:19:32.779: D/dalvikvm(263): GC_FOR_ALLOC freed 7K, 28% free 10448K/14471K, paused 128ms, total 134ms
11-14 14:19:32.920: D/dalvikvm(263): GC_CONCURRENT freed 1K, 27% free 10681K/14471K, paused 16ms+38ms, total 134ms
11-14 14:19:32.969: D/dalvikvm(146): WAIT_FOR_CONCURRENT_GC blocked 0ms
11-14 14:19:33.269: W/InputMethodManagerService(146): Found no subtypes in a system IME: com.android.inputmethod.pinyin
11-14 14:19:33.349: W/RecognitionManagerService(146): no available voice recognition services found
11-14 14:19:33.899: D/dalvikvm(263): GC_CONCURRENT freed 3879K, 43% free 8263K/14471K, paused 34ms+10ms, total 114ms
11-14 14:19:33.949: I/Choreographer(263): Skipped 303 frames! The application may be doing too much work on its main thread.
11-14 14:19:34.249: D/dalvikvm(263): GC_FOR_ALLOC freed 115K, 40% free 8702K/14471K, paused 50ms, total 51ms
11-14 14:19:34.369: D/dalvikvm(263): GC_FOR_ALLOC freed 327K, 38% free 8973K/14471K, paused 39ms, total 42ms
11-14 14:19:34.619: D/dalvikvm(263): GC_CONCURRENT freed 767K, 37% free 9191K/14471K, paused 39ms+6ms, total 94ms
11-14 14:19:34.619: D/dalvikvm(263): WAIT_FOR_CONCURRENT_GC blocked 44ms
11-14 14:19:34.619: D/dalvikvm(263): WAIT_FOR_CONCURRENT_GC blocked 47ms
11-14 14:19:34.789: D/dalvikvm(263): GC_FOR_ALLOC freed 232K, 37% free 9257K/14471K, paused 49ms, total 55ms
11-14 14:19:34.799: I/dalvikvm-heap(263): Grow heap (frag case) to 10.314MB for 1286224-byte allocation
11-14 14:19:34.879: D/dalvikvm(263): GC_FOR_ALLOC freed 3K, 28% free 10509K/14471K, paused 78ms, total 78ms
11-14 14:19:35.009: D/dalvikvm(263): GC_CONCURRENT freed 26K, 28% free 10510K/14471K, paused 27ms+7ms, total 132ms
11-14 14:19:35.149: D/dalvikvm(146): GC_EXPLICIT freed 520K, 10% free 9550K/10567K, paused 116ms+516ms, total 2113ms
11-14 14:19:35.159: D/AndroidRuntime(1359): Shutting down VM
11-14 14:19:35.179: D/dalvikvm(1359): GC_CONCURRENT freed 101K, 78% free 459K/2048K, paused 0ms+1ms, total 10ms
11-14 14:19:35.179: D/jdwp(1359): Got wake-up signal, bailing out of select
11-14 14:19:35.179: D/dalvikvm(1359): Debugger has detached; object registry had 1 entries
11-14 14:19:35.189: I/AndroidRuntime(1359): NOTE: attach of thread 'Binder_3' failed
11-14 14:19:35.759: D/AndroidRuntime(1377): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
11-14 14:19:35.759: D/AndroidRuntime(1377): CheckJNI is ON
11-14 14:19:35.799: D/dalvikvm(1377): Trying to load lib libjavacore.so 0x0
11-14 14:19:35.799: D/dalvikvm(1377): Added shared lib libjavacore.so 0x0
11-14 14:19:35.829: D/dalvikvm(1377): Trying to load lib libnativehelper.so 0x0
11-14 14:19:35.829: D/dalvikvm(1377): Added shared lib libnativehelper.so 0x0
11-14 14:19:36.509: D/AndroidRuntime(1377): Calling main entry com.android.commands.am.Am
11-14 14:19:36.529: I/ActivityManager(146): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.facebook/.MainActivity u=0} from pid 1377
11-14 14:19:36.539: W/WindowManager(146): Failure taking screenshot for (164x246) to layer 21020
11-14 14:19:36.579: D/AndroidRuntime(1377): Shutting down VM
11-14 14:19:36.590: D/dalvikvm(1377): GC_CONCURRENT freed 102K, 77% free 489K/2048K, paused 1ms+1ms, total 11ms
11-14 14:19:36.590: D/jdwp(1377): Got wake-up signal, bailing out of select
11-14 14:19:36.590: D/dalvikvm(1377): Debugger has detached; object registry had 1 entries
11-14 14:19:36.599: I/AndroidRuntime(1377): NOTE: attach of thread 'Binder_3' failed
11-14 14:19:36.609: D/dalvikvm(1387): Not late-enabling CheckJNI (already on)
11-14 14:19:36.630: I/ActivityManager(146): Start proc com.example.facebook for activity com.example.facebook/.MainActivity: pid=1387 uid=10054 gids={3003, 1028}
11-14 14:19:36.630: I/Choreographer(263): Skipped 46 frames! The application may be doing too much work on its main thread.
11-14 14:19:36.929: E/Trace(1387): error opening trace file: No such file or directory (2)
11-14 14:19:38.359: D/dalvikvm(1387): GC_CONCURRENT freed 284K, 6% free 6199K/6535K, paused 72ms+84ms, total 206ms
11-14 14:19:39.219: I/Choreographer(1387): Skipped 39 frames! The application may be doing too much work on its main thread.
11-14 14:19:39.239: D/gralloc_goldfish(1387): Emulator without GPU emulation detected.
11-14 14:19:39.279: I/ActivityManager(146): Displayed com.example.facebook/.MainActivity: +2s710ms
11-14 14:19:39.443: I/Choreographer(1387): Skipped 60 frames! The application may be doing too much work on its main thread.
11-14 14:19:39.449: I/Choreographer(263): Skipped 51 frames! The application may be doing too much work on its main thread.
11-14 14:19:39.459: I/Choreographer(146): Skipped 57 frames! The application may be doing too much work on its main thread.
11-14 14:19:39.551: I/Choreographer(146): Skipped 44 frames! The application may be doing too much work on its main thread.
11-14 14:19:39.679: I/Choreographer(146): Skipped 49 frames! The application may be doing too much work on its main thread.
11-14 14:19:39.759: I/Choreographer(146): Skipped 49 frames! The application may be doing too much work on its main thread.
11-14 14:19:39.852: I/Choreographer(146): Skipped 43 frames! The application may be doing too much work on its main thread.
11-14 14:19:41.122: I/Choreographer(146): Skipped 43 frames! The application may be doing too much work on its main thread.
11-14 14:19:41.239: I/Choreographer(146): Skipped 48 frames! The application may be doing too much work on its main thread.
11-14 14:19:41.319: I/Choreographer(146): Skipped 44 frames! The application may be doing too much work on its main thread.
11-14 14:19:41.391: I/Choreographer(146): Skipped 44 frames! The application may be doing too much work on its main thread.
11-14 14:19:41.471: I/Choreographer(146): Skipped 43 frames! The application may be doing too much work on its main thread.
11-14 14:19:41.568: I/Choreographer(146): Skipped 44 frames! The application may be doing too much work on its main thread.
11-14 14:19:41.681: I/Choreographer(146): Skipped 43 frames! The application may be doing too much work on its main thread.
11-14 14:19:41.761: I/Choreographer(146): Skipped 44 frames! The application may be doing too much work on its main thread.
11-14 14:20:00.092: I/Choreographer(217): Skipped 43 frames! The application may be doing too much work on its main thread.
感谢任何可以提供帮助的人。
最佳答案
首先,您选择了错误的标签
来进行获取用户位置的查询。
如果您使用的是图谱 API,则相关的 标签
是:location。您使用的 user_location
是一个权限。
其次,也许更重要的是,您选择了这些权限:{"email", "publish_stream"}
要获取用户的生日
和他/她的位置
,您还需要这些权限:对于登录到您的应用的用户:user_location
。并获取登录用户的好友位置:friends_location
同样,对于生日
,您将需要这些权限:登录用户的user_birthday
和登录用户的 friend 的friends_birthday
.
在此处查看用于查询和获取结果的可用字段列表:https://developers.facebook.com/docs/reference/api/user/
有关所有权限的列表,请查看此页面:https://developers.facebook.com/docs/reference/login/#permissions
编辑 2:
删除早期的 FQL 建议并提供替代方案。
String testURL = "https://graph.facebook.com/me?fields=name,birthday,email,location&access_token=YOUR_ACCESS_TOKEN";
try {
HttpClient hc = new DefaultHttpClient();
HttpGet get = new HttpGet(testURL);
HttpResponse rp = hc.execute(get);
if (rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String result = EntityUtils.toString(rp.getEntity());
JSONArray JAUserInfo = new JSONArray(result);
for (int i = 0; i < JAUserInfo.length(); i++) {
JSONObject JOUserInfo = JAUserInfo.getJSONObject(i);
Log.e("USER DETAILS", JOUserInfo.toString());
if (JOUserInfo.has("location") {
JSONObject JOLocation = JOUserInfo.optJSONObject("location");
String location = JOLocation.getString("name");
}
}
}
} catch (Exception e) {
// TODO: handle exception
}
注意:您需要在此查询中提供访问 token 。没有它,这无疑会失败。只需将 String testURL
中的 YOUR_ACCESS_TOKEN 更改为您的访问 token 。
关于android - 在 Android 中从 Facebook SDK 获取所有信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13356267/
03-25 05:52:15.329 8029-8042/com.mgh.radio W/MediaPlayerNative: info/warning (703, 0) 03-25 05:52:15
我一直在 Internet 上到处寻找关于 FrameworkElementFactory 类的适当文档,但我似乎找不到有关它的适当教程或有用信息。 请问对这个问题了解更多的人可以给我更多的信息吗?这
我需要知道一个线程在进入等待状态之前如何将其ID发送到另一个线程。我想传递一个带有其ID的变量,但我不知道该怎么做。 最佳答案 如果只有一个线程及其父线程,则可以使用全局变量,因为它们在所有线程之间共
我正在尝试制作一个程序,该程序可以读取命令行上的所有单词,然后将其打印在新行上,而我想要做的是这样的: Some text: hello 但是相反,我得到了这样的东西: Some text: Hell
我有一个连接到rabbitmq服务器的python程序。当该程序启动时,它连接良好。但是当rabbitmq服务器重新启动时,我的程序无法重新连接到它,并留下错误“Socket已关闭”(由kombu产生
我正在设置CI / CD管道。部署步骤运行以下命令: kubectl apply -f manifest.yml --namespace kubectl rollout status Deploym
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
这是我在文件上运行 svn info 时输出的一部分: Last Changed Author: [user] Last Changed Rev: 269612 Last Changed Date:
所以我正在构建这个音乐应用程序,到目前为止它只扫描 SD 卡内的特定文件夹。这将返回路径,然后播放它们。 几个小时前我得知android系统中有一个媒体文件数据库所以 我想知道这个媒体文件数据库是否存
我正在绘制树形图,并且想知道如何绘制树类的相对百分比,即 A组=100 B地=30 C地=50 D 地 =20 然后,在图中,应该添加: A 组“50%” B 组“15%” 等在其“Group X”标
我正在构建一个社交网站,我想知道如何在用户首次登录时显示交互式教程和信息。比如只有在第一次登录时,用户才会被要求在他们的个人资料中填写更多信息。我怎样才能通过 php 和 mysql 实现这一点?例子
我是 java servlet 的新手。我研究了一些关于 servlet 的代码,但我真的很想知道更多基本的东西以及它是如何工作的。我只是想知道什么类型的 Material /内容可以从 java s
我想知道是否有办法为 user_id、sender_user_id 和 recipient_user_id 提供 name 信息来自 this fiddle 中的模式. 我现在唯一能想到的办法就是做这
这是我存储2个大学生信息的源代码。我想从输入中获取每个人的姓名、姓氏、ID 和 5 分,然后在输出中显示它们。我在输出中显示分数时遇到问题。 请帮忙 #include using namespace
假设我有一张带有条形图的图像,如下所示: 我想提取条形图和标签的值,除了训练 ML 模型之外,还有其他方法吗? 我有一堆图像,我为其生成了图表和一些描述。我目前正尝试仅从我能够做到的描述中提取信息,但
有没有办法从 GKTurnBasedParticipant 对象中检索玩家的名字?似乎除了根据类引用的难看的 playerID 之外,没有办法显示有关游戏玩家的相关信息。还是我遗漏了什么? 谢谢...
我有一个随机抛出“KeyNotFoundException”的 C# Silverlight 应用程序。我不知道找不到什么 key 。这让我想到了两个问题: KeyNotFoundException
本文实例为大家分享了ios获取本地音频文件的具体代码,供大家参考,具体内容如下 获取本地音频文件地址: ?
下面为大家介绍利用SQL查询语句获取Mysql数据库中表的表名,表描述、字段ID、字段名、数据类型、长度、精度、是否可以为null、默认值、是否自增、是否是主键、列描述 1、查询表信息(表名/表
问题 有没有办法获取代码中使用属性的位置,或声明成员变量的位置? 我不是在寻找解决此问题的方法,只是寻求一个简单的答案,无论这在技术上是否可行。 一些背景信息 我已经定义了一个属性,该属性使用提供给属
我是一名优秀的程序员,十分优秀!