How do I get a users online status via the slack api? - slack-api

the users active/away status does not appear to be listed here:
https://api.slack.com/types/user
is there another method to query this information that I missed?

Maybe you noticed it by now, but there is a method named users.getPresence in the Slack API.
Example of querying the API, given that you have created a token (token=xoxp-313xxxxxx-313xxxxxx-313xxxxxx-xxxxxx) and you are looking for the user with the ID U03xxxxxx.
curl -X POST https://slack.com/api/users.getPresence
--data "token=xoxp-313xxxxxx-313xxxxxx-313xxxxxx-xxxxxx&user=U03xxxxxx"
Response:
{"ok":true,"presence":"away"}
Note that you can get user ids, with the method users.list or users.info.
REF: https://api.slack.com/methods

Currently there's the status key on user objects returned from
https://slack.com/api/users.info

I think the most easier way for this > get all user presence status (up to 1000 users) quickly is the users.list method.
https://api.slack.com/methods/users.info
https://slack.com/api/users.list?token=xoxp-173888888-XXXXXXXX-YYYYYYYY-ZZZZZZZZ&presence=true&pretty=1
Please don't forget to read the documentation, sometimes the limit at 200.

Related

Where did the Shopify webhook for order update go?

I need to subscribe to the order update Shopify webhook. The thing is, is I can't find it! They have changed the way the shopify_app.rb config file is structured. So this is the way it looks now:
config.scope = "read_shipping, write_shipping, read_products, write_products,
read_fulfillments, write_fulfillments, read_orders, write_orders, read_themes, write_themes, orders/updated"
Looking at the Shopify docs it doesn't look like the order update hook exists anymore. According to their own docs
But there is this old doc that does contain the order update hook: https://help.shopify.com/en/api/reference/events/webhook
I put that style into my config.scope line but I got this when I try and install: https://nimb.ws/JH267z
Any ideas?
EDIT: I'm just trying sh*t now.. I tried update_orders and that didn't work: https://nimb.ws/Yun5Us
Scope has nothing to do with Webhook subscriptions. If you subscribe to a webhook like orders/update, then you receive orders at your designated end point when the update occurs.
Scope is more of an authorization tool, for API access to endpoints at Shopify. No matter what you do with scope, it will not add a webhook subscription for you. For that, you call the Webhook endpoint and add the webhook you need.

getting transaction id from org.neo4j.driver.v1.Transaction api (bolt api)

How to get transaction id from org.neo4j.driver.v1.Transaction api.
I did not see any method to get that.
Can anybody help
Currently, the 2 implementations of the org.neo4j.driver.v1.Transaction interface do not store anything like a "transaction id".

Get all liked pages sorted by general likes

I'm trying to get Pages liked by the user ordered descending by amount of likes each Page has...
It's difficult to get this using Graph API cause I'd have to fetch request like this:
let request = FBSDKGraphRequest(graphPath: "me/likes" parameters: nil)
and recursively call this inside because this request will paginate response. After I get everything I'll have to sort it locally and that's how I'd get it 😬
IMHO, it's a lil bit overkill so I've looked into a method of achieving same thing but using FQL and this is the query:
SELECT name, fan_count FROM page WHERE page_id IN (SELECT page_id FROM page_fan WHERE uid = me()) ORDER BY fan_count DESC
At first I was happy with this but after some test my friend told me that he can't see Messi on his list. So I wonder what's the reason that not all Pages are show in this FQL query result?
You don’t have to make separate requests for this.
The Graph API has a feature called “field expansion”, that allows you to specify that you want data from multiple “levels” in one go. https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#fieldexpansion
So requesting
/me/likes?fields=id,name,likes
will give you the id, name and number of likes for each of the user’s liked pages.
(You will still have to follow the pagination links, gather all results and do the sorting on your end afterwards, since the API doesn’t currently allow for sorting.)
FQL is deprecated and only works with older Apps using v2.0 of the Graph API. As of now, the only way to do this is to recursively get all Pages and do the sorting on your own.

Api to post a comment in instagram using instagram gem?

I have tried by using the following code,
client = Instagram.client(:access_token => "My_Access_Token")
result = client.create_media_comment("Media_Id", "Comment")
but i'm getting the following error,
POST https://api.instagram.com/v1/media/Media_Id/comments.json: 400: Please visit http://bit.ly/instacomments for commenting access
How can i resolve this?
You should be passing an actual id for the piece of Instagram media on which you want to create a comment rather than the "Media_Id" string.
Your code is correct (otherwise you won't get that error).
You need to go to http://bit.ly/instacomments and ask for commenting permission. Don't expect a reply anytime soon though, I've been waiting for a reply over a month, and seen people getting replies for that after three or four months.

Twitter API with rails

I'm trying call the "lookup" method on multiple users on Twitter. According to the documentation, this is feasible.
http://apiwiki.twitter.com/w/page/24142947/Twitter-REST-API-Method:-users-lookup
I'm calling the method and stringing together 5 IDs separated by commas.
Here's my call:
access_token = twitter_oauth_access_token(user.twitter.token, user.twitter.secret)
response = access_token.get("/users/lookup.json?user_id=#{ids.join(',')}")
ActiveSupport::JSON.decode(response.body)
I've verified that there are multiple IDs in the "ids" variable. The problem is that no matter how I call it, I only get the first one in the list back. So the call is successful, but it doesn't give me the list of results as the documentation says.
Any idea what I might be doing wrong?
I figured it out. The API URL was incorrect. It should've been:
access_token.get("/1/users/lookup.json?user_id=#{ids.join(',')}")
instead of
access_token.get("/users/lookup.json?user_id=#{ids.join(',')}")

Resources