谷歌云消息传递时间(Google cloud messaging time to live)
我正在开发使用GCM的android应用程序,但是如果用户手机不在线,我想取消消息传递。 有没有办法将生存价值的时间减少到最低限度?
I was developing android application which uses GCM, but I want to cancel message delivery if user phone is not online. Is there any way to decrease time to live value to minimum?
原文:https://stackoverflow.com/questions/19201130
最满意答案
那么,首先,请务必要求
friends_birthday
权限,否则无法获得朋友的生日日期。如果您对Graph API Explorer不熟悉,则应该 - 您可以测试FQL查询以查找问题。
点击“获取访问令牌”,然后在“朋友数据权限”中选中“friends_birthday”,您就可以开始测试查询了。
其次,所有的生日都与实际出生年份一起存储,所以
above today
在FQL查询中询问above today
内容总是不会返回任何结果。 为了“修复”日期 - 你实际上可以选择生日和今年的一部分,如下所示:SELECT name, birthday, birthday_date, concat(substr(birthday_date,0,6),"2013") FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null'
问题来了:
所选字段不是用户表的一部分,您无法对其进行排序,甚至无法使用WHERE。 我的猜测是,你必须让所有的朋友过生日,并使用JAVA过滤数据 - 这应该很容易,因为自定义选择字段中的日期是2013年而不是实际年份。
随意使用此链接测试 FQL。
编辑#1
我想澄清一些事情,你想转换的原始查询不会
在未来30天内获取Facebook朋友的生日列表
当在查询中手动替换值时,我看到它返回了生日在同一个月的两个给定日期之间的所有朋友。 它没有找到所有在未来30天有生日的朋友。
编辑#2
我已经找到了一种方法让这个月和下一个生日的所有朋友 - 这是更好的通过所有的朋友名单。
SELECT name, birthday, birthday_date, concat(substr(birthday_date,0,6),"2013") FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND (substr(birthday_date,0,2)='02' OR substr(birthday_date,0,2)='03')
这应该会变得更容易在今天之前超过列表并过滤掉这些列表,并且从今天起不超过30天 - 这是我能想到的最佳解决方案。
编辑#3我实际上可以使用来自编辑#2的相同查询进行过滤,以获得今天之后的所有内容,并按其排序:
SELECT name, birthday, birthday_date, concat(substr(birthday_date,0,6),"2013") FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND (substr(birthday_date,0,2)='02' OR substr(birthday_date,0,2)='03') AND birthday_date > '02/23/2013' ORDER BY birthday_date
如果你想限制10:
SELECT name, birthday, birthday_date, concat(substr(birthday_date,0,6),"2013") FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND (substr(birthday_date,0,2)='02' OR substr(birthday_date,0,2)='03') AND birthday_date > '02/23/2013' ORDER BY birthday_date LIMIT 10
编辑#4
如果您计算Java中的日期并将其传递给查询,则更为简单
SELECT name, birthday, birthday_date FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND birthday_date > '02/23/2013' AND birthday_date < '04/24/2013' ORDER BY birthday_date ASC
编辑#5
一些Java代码:
Calendar cal = Calendar.getInstance(); Date today = cal.getTime(); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); String today_formatted = formatter.format(today); cal.add(Calendar.DATE, 30); String today_plus30_formatted = formatter.format(cal.getTime()); String query = "SELECT name, birthday, birthday_date FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND birthday_date > '" + today_formatted + "' AND birthday_date < '" + today_plus30_formatted + "' ORDER BY birthday_date ASC";
我没有测试过它,没有安装Java :-)
Well, first of all, make sure to ask for
friends_birthday
permission, without it you can't get your friends birthday dates.If you are not familiar with the Graph API Explorer, you should - you can test FQL queries to find problems.
Click the "Get Access Token" and in "Friends Data Permissions" check the "friends_birthday" and you are good to go testing the query.
Second, all the birthdays are stored with the actual birth year, so asking for
above today
in FQL query will always return nothing. to "fix" the date - you can actually select a portion of the birthday and this year to it like so:SELECT name, birthday, birthday_date, concat(substr(birthday_date,0,6),"2013") FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null'
And here comes the problem:
The selected field is not part of the user table, and you can't sort by it, or even use WHERE on it. My guess is that you have to get all your friends birthday and use JAVA to filter the data - It should be easy since the date in the custom selected field has 2013 instead of the real year.
Feel free to Test the FQL with this link.
EDIT #1
I want to be clear on something, the original query you wish to convert will not
fetch list of Facebook friends those birthdays in next 30 days
When replacing the values manually in the query I saw that it returns all friends with birthday between 2 given days in the same month. It does not find the all the friends who has a birthday in the next 30 days.
EDIT #2
I have found a way to get all friends with birthday in this month and the next - which is much better the to go over all the friends list.
SELECT name, birthday, birthday_date, concat(substr(birthday_date,0,6),"2013") FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND (substr(birthday_date,0,2)='02' OR substr(birthday_date,0,2)='03')
This should become much easier to go over the list and filter the ones before today and no more then 30 days from today - this is the best solution I can think of.
EDIT #3 I can actually filter using the same query from edit #2 to get all the ones after today, ordered by it:
SELECT name, birthday, birthday_date, concat(substr(birthday_date,0,6),"2013") FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND (substr(birthday_date,0,2)='02' OR substr(birthday_date,0,2)='03') AND birthday_date > '02/23/2013' ORDER BY birthday_date
And if you want to limit by 10:
SELECT name, birthday, birthday_date, concat(substr(birthday_date,0,6),"2013") FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND (substr(birthday_date,0,2)='02' OR substr(birthday_date,0,2)='03') AND birthday_date > '02/23/2013' ORDER BY birthday_date LIMIT 10
Edit #4
Much more simple if you calculate the dates in Java and pass it to the query
SELECT name, birthday, birthday_date FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND birthday_date > '02/23/2013' AND birthday_date < '04/24/2013' ORDER BY birthday_date ASC
EDIT #5
Some Java code:
Calendar cal = Calendar.getInstance(); Date today = cal.getTime(); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); String today_formatted = formatter.format(today); cal.add(Calendar.DATE, 30); String today_plus30_formatted = formatter.format(cal.getTime()); String query = "SELECT name, birthday, birthday_date FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND birthday_date > '" + today_formatted + "' AND birthday_date < '" + today_plus30_formatted + "' ORDER BY birthday_date ASC";
I have not tested it, don't have Java installed :-)
相关问答
更多-
我想我明白你想要什么。 为什么不创建一个数月的数组来构建div然后在该div中显示该月份的生日用户... $months = array('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'); foreach($months as &$month){ ?>// loop through users with birthday in $month ...api响应实际上是一个数组,其中的朋友数据在['data']键中,所以循环应该是 foreach ($user_friends['data'] as $friend) The api response is actually an array, with the friends data in the ['data'] key, so the loop should be foreach ($user_friends['data'] as $friend)
android facebook fql这是用户的朋友使用我的应用程序(android facebook fql thats get friends of user using my appliction)[2022-04-10]
您将它添加到WHERE子句 SELECT uid, name, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user You add it to the WHERE clause SELECT uid, name, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND ...那么,首先,请务必要求friends_birthday权限,否则无法获得朋友的生日日期。 如果您对Graph API Explorer不熟悉,则应该 - 您可以测试FQL查询以查找问题。 点击“获取访问令牌”,然后在“朋友数据权限”中选中“friends_birthday”,您就可以开始测试查询了。 其次,所有的生日都与实际出生年份一起存储,所以above today在FQL查询中询问above today内容总是不会返回任何结果。 为了“修复”日期 - 你实际上可以选择生日和今年的一部分,如下所示: SE ...你得到的是uid。 您的朋友在“我的查询”中会得到相同的ID。 You're getting the uid. The same id your friend would get in a "me query".Bundle params = new Bundle(); params.putString("fields","birthday"); JSONObject jObject1 = new JSONObject(authenticatedFacebook.request("me/friends",params)); 现在,如果你打印jobject1,你会得到你所有的朋友生日列表.. 响应将采用JSON格式,您必须从中获得价值。 认证Facebook是你的对象Facebook .. 为了进一步 ...获取所有使用FQL的朋友(Get all Friends using FQL)[2023-01-26]
除非您使用的是v1.0应用程序,否则API调用只会使用该应用程序返回朋友。 朋友列表现在只返回同时使用您的应用的朋友:通过/ me / friends端点返回的朋友列表现在仅限于已授权您的应用的朋友列表。 https://developers.facebook.com/docs/apps/changelog 这也适用于FQL好友表。 Unless you are using a v1.0 application that API call will only return friends using the ...搜索朋友FQL很慢(Search friends FQL is slow)[2023-08-21]
每次用户添加角色时,发出新请求并不是一个好主意。 您应该使用页面本身一次性加载您的朋友。 或者更好的是,您可以在页面完全加载后使用AJAX透明地执行此操作。 然后,您将避免任何慢速请求,因为您已经有了用户的朋友。 结果立竿见影。 为此,我建议您使用jQuery Autocomplete插件 。 That's not a good idea to make a new request each time the user adds a character. You should load your frien ...当朋友使用它时,也可以删除应用程序访问数据的能力,此选项将阻止当前会话用户通过API查看有关其朋友的一些信息,即使该信息可在Facebook.com上访问 此设置位于隐私设置中,位于https://www.facebook.com/settings/?tab=privacy ,广告,应用和网站下 - >“人们如何将您的信息带到他们使用的应用中”,如下所示: {edit}你可以为测试用户自己测试一下,这是假设你在前端看到生日的最可能的原因 It's also possible to remove the ab ...如何使用Hackbook示例获取Facebook好友即将到来的生日(How to get Facebook Friends Upcoming Birthdays using Hackbook Example)[2021-08-31]
这里使用旧版SDK的一些代码试试这个 Facebook fb = new Facebook(main.APP_ID); SessionStore.restore(fb, mActivity); mAsyncRunner = new AsyncFacebookRunner(fb); String graphPath = "me/friends"; Bundle bundle_friends = new Bundle(); bundle_friends.putS ...相关文章
更多- Storm-源码分析- Messaging (backtype.storm.messaging)
- Real-Time Rendering 笔记 --- 1-4章
- The Log: What every software engineer should know about real-time data's unifying abstraction
- 什么是Spring Cloud
- tomcat中搭建solr Cloud、日志、多Core以及常见问题
- Cloud7为全球移动互联网大会提供手机门户支撑
- Hadoop在master查看live nodes为0解决方案
- opensource projects relevant version of cloud
- POJ 3620 Avoid The Lakes【DFS水题练格式Avoid The Lakes Time Limit: 1000MS Memory Limit: 65536K Total Sub】
- Twitter Storm中Bolt消息传递路径之源码解读
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。