Weibo error 20112 when attempting to access a user's post - api

I'm attempting to get a user's Weibo post with 2/statuses/show. I'm able to get posts made by my own account fine, but when I try to get another user's post I get the error:
{"error":"Permission Denied!","error_code":20112,"request":"/2/statuses/show.json"}
The Weibo docs say (via google translate):
20112: As the author privacy settings, you do not have permission to view this microblogging
Does this mean the author of the post needs to update their permissions to allow the developer account access?

I also encounter this issue. However, you can still access the post using its user_id and mid (in base62). For instance, you cannot get this post from the API (its id is 10031139424) but you can still see it from your webbrowser.
An alternative is to get the post from its mobile url. Then, you can get its json which is contained in the variable render_data from the body of the html.

Any posts can be setted to be unvisible but for microblogger himself or trusted groups.
So privacy settings lead to your problem.

Related

Google Classroom API courses.teachers.create

I'm trying to use the courses.teachers.create method but I can't get it to work, error 403 returns.
code 403 message {The caller does not have permission} status PERMISSION_DENIED
My API if authorized to allow users to create courses, according to the scope indicated in the API documentation.
And already check the user and if you have CREATE permissions but it still does not work, it is the only method that does not work for me, because when I try to eliminate a teacher everything works correctly.
I already did tests on the API reference page and it shows me the same error.
I found the problem, and it is because to be able to create teacher it is necessary that my account be a domain administrator.

How can a webhook identify USER_IDs?

I'm developing a webhook, and I want it to be able to #mention specific users. The simple message format specifies using the format of <users/123456789012345> to #mention a specific users. Since this is not a bot, it is not processing an incoming message and cannot pull the from the sender field, as suggested in the note on the developer site linked above.
How can I get the USER_ID of a user on my domain?
I am in the same boat as you. Trying to use a Webhook to mention a user.
If you inspect the HTML on https://chat.google.com, using web/dev tools, you can actually see user ID under tag data-member-id="user/bot/123456789012345"
Using the above I tried to form a webhook that mentioned the user (in my case another bot).
Unfortunately it didn't work. Passing in the string <users/123456789012345> please test came through to chat as a string literal.
It's strange because the html links and markup DO get interpreted. As mentioned here. Edit: so does <users/all>.
I'm leaving this here since your question asks for how to elicit the ID. While it may not be pretty, or much automatable, it helped me get the user ID at least.
Edit 2: It works, just not to mention my other bot for some reason. But using this method I was able to mention a human user :)
I use this for find the USER_ID but if you have another way let me know
Right click on the user and select inspect
Search for data-member-id this is your USER_ID
A webhook will not be able to pull the USER_ID of a user. As a workaround for this, you can create a service account and a bot that has access to the room and use the REST API spaces.members.list() and spaces.members.get() method.
Note: The bot will need to be added to the room.
Okay, so in order to get the UserID without having to do all of the things that you're trying to do here you need to use the Admin SDK API in google app script. Basically what you'll want to do is use your google app script as an intermediary for what you're trying to do. So you'll post something to google app script via their web exec functions on a deployed app and then have that app communicate to the google chat API via something like this:
var googlewebhookurl = 'https://chat.googleapis.com/v1/spaces/ASDFLKAJHEPQIHEWFQOEWNQWEFOINQ';
var options = {
'method': 'post',
'contentType': 'application/json',
'payload' : JSON.stringify({ text: "<users/000000000001> I see you!" })
}
UrlFetchApp.fetch(googlewebhookurl, options);
To start, you'll need to add the Admin SDK API to the services in your google app script services area. So click the plus next to "Services" and then select the Admin SDK API and click add to add it to the services, it winds up showing up in the list as "AdminDirectory" once it has been added to the services.
This is an image showing what it looks like once you've added it to the services.
Here is a link to the documentation for the Admin SDK API getting user information: https://developers.google.com/apps-script/advanced/admin-sdk-directory#get_user
You should be able to copy and paste that example function to get the information you're looking for regarding the user. I'm pasting the example code below in case something happens to this link:
/**
* Get a user by their email address and logs all of their data as a JSON string.
*/
function getUser() {
var userEmail = 'liz#example.com';
var user = AdminDirectory.Users.get(userEmail);
Logger.log('User data:\n %s', JSON.stringify(user, null, 2));
}
In order to get the user id, take the user variable that comes back and access user.id and voila! You have the ID you're looking for. From there just plaster it into a text message in google chat and you should be in business. I haven't gotten it to work with cards at all yet. I'm not seeing any documentation saying that it's supported in cards at all. For more information regarding chat messages and cards take a look at these:
https://developers.google.com/chat/api/guides/message-formats/basic
https://developers.google.com/chat/api/guides/message-formats/cards

status page empty

I'm trying to display my Facebook status on my personal website. I tried this great tutorial http://johndoesdesign.com/blog/2011/php/adding-a-facebook-news-status-feed-to-a-website
The code work great for a couple of Facebook page that I own. But for a specific FB Page I get to step 4 and then get nothing.
{
“data”: [
]
}
Not sure what I’m doing wrong? Any thoughts
The Facebook Page is http://facebook.com/KINGDOM.Gentlemans.Club
(remove space after http://)
The Facebook Page_ID is
114357805248420
Example
https://graph.facebook.com/114357805248420/feed?access_token=???????
Does someone know why I get a blank data page?
Thank you
Marc
I can't find your page on Facebook (over 21 from the USA), so your problem is one of two things:
Your ID and page username are wrong. I should be able to see your page at facebook.com/USERNAME or facebook.com/PAGE_OR_USER_ID. I can't see it at either of these from the information in your original post.
You've got country and/or age restrictions on your page. If that's the case, your generic App access token isn't going to work. To show the feed of a restricted page on a website, Facebook requires you use the access token of a user who has permission to see your page. This prevents your restricted content from being shown to people who shouldn't be looking at it. If you don't have any restrictions on your site, then you don't need an access token to view the results.
BTW, don't EVER post real access tokens on SO. Anyone can harvest and use them. You should reset your KingomFeed app access token NOW.

How do i send twitter direct messages on behalf of logged in user?

I have a twitter app with access level "Read, write, and direct messages"
I am using omniauth-twitter gem along with devise for letting users sign up and log into my site through twitter. All is fine till now.
It would be nice if the user is able to send direct messages to the his/her followers.
To fetch the list of followers I am using twitter gem. Now how do I let the user send the message he wants?
I have tried almost anything but all returns This application is not allowed to access or delete your direct messages error. This has been killing me for the past week
When I do Twitter.verify_credentials there is no error raised and a User object is returned. But when I call Twitter.direct_messages the above errors is raised. Am i missing something obvious here?
Thanks in advance.
Update: When I tried Twitter.direct_message_create() it worked like a charm! Would like to know as to why Twitter.direct_messages didn't work.
Check https://twitter.com/settings/applications to make sure that DM permissions are actually authorized. If not revoke and reauthorize. Make sure the OAuth tokens the account has granted to the app actually include DM access. Sometimes an app will not have DM acces, OAuth tokens will get authorized then DM access gets added to the app settings and the OAuth token for the account doesn't have DM access authorized.
To answer your update question:
Update: When I tried Twitter.direct_message_create() it worked like a
charm. Would like to know as to why Twitter.direct_messages didn't
work.
Twitter.direct_message(id)
Is used to retrieve existing DMs, whereas:
Twitter.direct_message_create(user, text)
is used to send a DM.
See here: http://rubydoc.info/github/jnunemaker/twitter/master/Twitter/Client/DirectMessages
As an update to #auxbuss's answer, the method has been renamed to:
Twitter.create_direct_message(user,text,options={})
The documentation has also moved:
http://rubydoc.info/github/sferik/twitter/master/Twitter/REST/DirectMessages.

API: Autosubmitting urls without required user_id gives OK

I autosubmitted an url through the flattr api with the url posted to /rest/v2/flattr, but without the user_id query parameter. The submit went through just fine but now there is no owner for the thing: see https://api.flattr.com/rest/v2/things/504370.
Well, problem is, it cant get flattred and I cannot assign myself as the owner, and it's for my node-flattr project page on github. What to do?
You can submit things without a user. We find the owner and then set the correct user id. Try to connect your flattr account with your github account. This will move the thing over to you.