toofusan / twity Goto Github PK
View Code? Open in Web Editor NEWTwitter API Client for Unity C# (ex-name: twitter-for-unity)
License: MIT License
Twitter API Client for Unity C# (ex-name: twitter-for-unity)
License: MIT License
used the same code for uploading image:
byte[] binary = File.ReadAllBytes(filepath);
string binary64 = System.Convert.ToBase64String(binary);
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["media_data"] = binary64;
StartCoroutine(Twity.Client.Post("media/upload", parameters, MediaUploadCallback));
Getting this response from Twitter:
{"request":"\/1.1\/media\/upload.json","error":"media type unrecognized."}
Hi, I'm using Twity.TweetObjectWithUser to get informations about a tweet and its user.
I get the proper profil pic, the name and every information I need on the tweet but the user.profile_text_color always returns the value 333333 when it should change depending on the user.
I upgraded to 2017.3 and it broke my Twity '-( so I downgraded again. I guess @toofusan is aware of this because the readme specifically says that Twity is compatible with up to 2017.2 . I wanted to create the issue anyway so that I will be informed if Twity gets updated to work with 2017.3!
Twitter has a repository whose name is "Twitter Kit for Unity" from Jul 14, 2017.
I should to avoid a similar name to the official tool, so I would change repository name and namespace.
Because the method uses multipart POST, OAuth is handled differently. POST or query string parameters are not used when calculating an OAuth signature basestring or signature. Only the oauth_* parameters are used.
https://developer.twitter.com/en/docs/media/upload-media/uploading-media/media-best-practices
Kinda new to Twitter APIs, this call seems straightforward enough for a response I get:
{"errors":[{"code":34,"message":"Sorry, that page does not exist."}]}
Heres the API docs.
https://developer.twitter.com/en/docs/trends/trends-for-location/api-reference/get-trends-place
Heres the calling code:
Twity.Oauth.consumerKey = "blah"; Twity.Oauth.consumerSecret = "blah"; StartCoroutine(Twity.Client.Get("trends/place", trendsParameters, TrendsCallback));
Note: trendsParameters is serialized in the inspector with a key: id and value: 2347598
I think I found a bug in the TwitterOauth.cs file. I was having problems using PIN authentication. Got the request tokens, but was getting a "Reverse auth credentials are invalid" 401 error when getting the access tokens. Found out that the GenerateSignature() method in TwitterOauth.cs sets the tokens based on access token first (or lack thereof), then checks for the request token.
Original code, starting around line 50:
if (!string.IsNullOrEmpty(accessToken))
{
oauth_token = accessToken;
oauth_token_secret = accessTokenSecret;
}
else if (!string.IsNullOrEmpty(requestToken))
{
oauth_token = requestToken;
oauth_token_secret = requestTokenSecret;
}
Fixed code:
if (!string.IsNullOrEmpty(requestToken))
{
oauth_token = requestToken;
oauth_token_secret = requestTokenSecret;
}
else if (!string.IsNullOrEmpty(accessToken))
{
oauth_token = accessToken;
oauth_token_secret = accessTokenSecret;
}
I'm still testing this, but just an FYI in case you've noticed some weird behaviors similar to this bug. I'm not sure how this will behave if a second request token request is made (will probably fail due to the values already existing), so more refactoring may be necessary.
This library appears to work great if you already have an accessToken, but the requests needed to generate an access token have their own challenges, and would be great additions to this library.
twitter-for-unity is working great when I compile for Windows, but when I compile for webgl and run in a browser I get this:
Failed to load https://stream.twitter.com/1.1/statuses/filter.json: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. The response had HTTP status code 400.
I read around and it sounds it may be impossible to make it work due to Twitter API policy -- they don't support CORS headers. I figure I'd post an issue anyway to see if anyone has found a way to do it.
Readme has links to https://dev.twity.com/ . The SSL cert is wrong and even if you ignore that, the server just returns 400 for all pages.
Looks like Plugin itself (or Twitter API) doesn't allow "(" and ")" symbols when you do new Tweet with "statuses/update".
At this point the only solution I found is to remove brackets from text at all. It would be good to find a solution how to screen brackets symbols.
Twity doesn't work with endpoint "POST media/metadata/create"
Because
Content-Type
must be application/json; charset=UTF-8
or text/plain; charset=UTF-8
{
"media_id":"692797692624265216",
// image alt text metadata
"alt_text": {
"text":"dancing cat" // Must be <= 420 chars
}
}
https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create
These are the errors I get every time I alt-tab into Unity
Read only asset Packages/toofusan.twity/DataModels has no meta file.
Read only asset Packages/toofusan.twity/Helpers has no meta file.
Read only asset Packages/toofusan.twity/Scripts has no meta file.
Read only asset Packages/toofusan.twity/packages.config has no meta file.
Read only asset Packages/toofusan.twity/Twity.asmdef has no meta file.
Read only asset Packages/toofusan.twity/package.json has no meta file.
Read only asset Packages/toofusan.twity/README.md has no meta file.
Read only asset Packages/toofusan.twity/LICENSE.txt has no meta file.
Theres also 66 warnings becuse of this
Ignoring asset refresh of Packages/toofusan.twity/DataModels/Error because the folder it is in has not been imported yet!
Data keeps streaming in and my callback keeps getting called after I call Off() and get a "Connection Aborted" message.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.