Sending Tweets using the OS X Twitter Account

I am looking for a way to send Tweets using the OS X (10.8 and higher) Twitter Account.
I would prefer a way to show the OS X Tweet Window in which i could add the text to be tweeted, so that the user can review the text and send it manually then.

Has anybody already tried this with Xojo?
Any help is highly appreciated. :slight_smile:

I don’t recall seeing any platform API’s to do it. You may be able to do it with the notification window that has the tweet box. However I’m not sure thats necessarily permitted as I’m sure that uses Apple’s API key. You may need to use the traditional route of getting a Twitter API key, etc.

Sounds like something that could be done in AppleScript…

Maybe it’s possible by invoking the OS X Sharing menu?

Damn! I LOVE the MonkeyBread Xojo Plugins SO MUCH! :slight_smile:

The solution is to use the NSSharingServiceMBS class

That probably means there is an API for it, and something that can be included in MacOSLib.

There absolutely is. I spent some time trying to get it working a while back, but it looked like it was going to take more time than priorities would allow.

I found it here:

https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSSharingService_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40012270-CH1-SW2

A nice addition to MacOSLib, if I can make it work.

With MBS Plugins:

[code]dim s As New NSSharingServiceItemsMBS
s.AddText “Test”

Dim picker As New NSSharingServicePickerMBS(s)

dim v as NSViewMBS = b.NSViewMBS
dim r as NSRectMBS = v.bounds

// somehow Real Studio messes up the coordinate system
r = new NSRectMBS(r.Origin.x, r.Origin.y + 105, r.Size.Width, r.Size.Height)

picker.showRelativeToRect(r, v, picker.NSMaxYEdge)

End If[/code]

b is a BevelButton in this case.

And here is a Tweet sent by using Xojo and the OS X Sharing Service :slight_smile:

Nice. That will be helpful in determining what classes have to be included, and maybe creating a convenience method or class.

Well, there is nothing for me to do. NSSharingService and NSSharingServicePicker are already part of MacOSLib, complete with examples.

https://github.com/macoslib/macoslib

LOL, of course there is.

:slight_smile: