Facebook realtime api for feed - java

I have set up realtime feed update for user. So whenever a user comments or likes something, I get a update request from facebook.
{
object='user',
entry=[{
uid='1372299847',
id='1372299847',
time=1368760855,
changedFields=[feed]
}]
}
But this doesn't tell me what the update exactly was. I have to read that user's feed and see what is the new change and process it. If I get the id, then I can just request for that object and process it rather than reading his feed and getting the changes.
Is there any way to get what exactly was changed(id of the comment or status)?

Facebook doc says that you have to get the actual changeset via Graph API or FQL query. The notification you get tells you only the concerned user's ID.

Related

Fetch changed/new videos using YouTubeData API

I am using YouTube Data API v3 to authorize a user with my app to fetch the video details from their channels and their subscribed channels and index those details to Elasticsearch.
I'm following this SO Answer to fetch all videos under a channel. Now, I met with a situation that I had to take only new videos in my next fetch. But, when I fetch again it also contains the videos that are already fetched earlier. I didn't find anything on this on YouTube Data API's documentation. I think this requires any token or any cursor field that handles the changes.
Looking for some suggestions.
You can save the 'last fetch date' and then, use /search to filter by date adding publishedAfter as a filter in your request. You hace a lot of filters in the search like the channelId, channel type, etc.

What if android crash before saving the purchaseToken?

I'm doing my first project using in-app billing on Android but there one thing I don't get:
We need to keep the purchaseToken whenever the purchase was succesfull in order to consume it later on. But there is no way to recover it if we don't save it on the first time we receive it. So if for instance Android crashed or something happens before we have time to consume/to save this token, how should we do then ? We won't ever be able to consume the purchase anymore without this token (which would be terribly anoying)...
To recall, the purchase data is stored in a String in JSON format :
'{
"orderId":"GPA.1234-5678-9012-34567",
"packageName":"com.example.app",
"productId":"exampleSku",
"purchaseTime":1345678900000,
"purchaseState":0,
"developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
"purchaseToken":"opaque-token-up-to-1000-characters"
}'
Do you have any solution or explanation about something I would have misunderstood in the process?
Please refer to getPurchases() api in the following link:
https://developer.android.com/google/play/billing/billing_reference.html#getPurchases
As long as you have yet to consume a purchase, you can get the unconsume purchase from getPurchases() api call. Just call getToken() to retrieve purchaseToken.

How to send direct message via Firebase from user to user?

I am really rookie and need an advice.
I have read documentation, and as far as i understood if you need send direct message, follow next steps:
Make authentification, eventually you get Firebase TokenId and
userId
Send them to your server side and store it in DB
When you are going to send a message you need create json and put
inside topic text and resipent userId so on...
Send this json via HTTP to your server side
When server retrive this json, it should use Firebase API to
create new message bloc child with random name in firebase
Eventually server have to find recipent user in DB by userId that we get from message.
After server will find current recipent user by userId , next we should take firebase tokenId In order to sent notification .
And send recipent user notification with such data - name of new
message bloc child
Recipent will connect to this current bloc and retrive data
It is as i understood this consept, fix me please if smth wrong?
Your suggested approach sounds good. The most important thing to realize is that you require an app server to send a downstream message to a device. Using the database as the communication mechanism between the app and the app server is a popular approach.
You could also use Cloud Messaging's upstream capabilities. But I've never tried that approach, because the database works fine for me and I had little interest in learning yet another protocol (XMPP).
You can read how I implemented it in this Firebase blog post Sending notifications between Android devices with Firebase Database and Cloud Messaging.

How to get the recipient ID on Facebook API v2.4 and newer (RestFB/Facebook4J)

I'm trying to send messages to customers who want to know the current state of their order. Now I know that you can only send messages to someone who sent you a message because you need to have the specific recipient ID. The problem with this is that if I want to get the recipient ID I need to read my mailbox and therefore need the permission: read_mailbox. But read_mailbox is deprecated as of Facebook API v2.4 and newer. I don't think that it is impossible to do it though. Question beeing, how to do it with v2.4 or newer?
Edit: Thanks CBroe for the answer
Last problem now is that when I get a specific message it only gives me the created_time and the id back. Same thing when I try it with the GraphAPI Explorer
This:
JsonObject message = getFacebookClient().fetchObject("m_mid.1467893842385:ae7475981839704062", JsonObject.class);
Gives this:
{
"created_time": "2016-07-07T12:17:22+0000",
"id": "m_mid.1467893842385:ae7475981839704062"
}
What am I doing wrong? Am I missing a parameter or a permission?
No, this doesn’t need read_mailbox permission.
https://developers.facebook.com/docs/graph-api/reference/page/conversations#read:
A page access token with read_page_mailboxes permission is required.
So you have to ask for that permission, plus manage_pages of course (because you need the latter to get a page access token.)

How can I correlate the response from Google Checkout to the correct order in the database?

When I get the notifications from google at the callback URL I am unable to correlate the messages to the correct order in the database. Can I pass some identifier that would be sent back to me as a part of the callback notification? How is this done in general?
I am using the latest google-checkout-java SDK.
You should be able to use your merchant-private-data-section for this
<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">
<shopping-cart>
<merchant-private-data>
<your-ref>019b1723a2754981ed5bc24e6ac9f501</your-ref>
</merchant-private-data>
[...]
</shopping-cart>
</checkout-shopping-cart>
When you get the notification, you can read this data.
See also this question and especially this answer. I'd only note additionally that you don't have to use merchant-note (or your-ref), but can define any tags of your own as merchant-private-data is defined as a sequence of xs:any.
Hope that helps...

Categories