Log in

No account? Create an account
LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Allowmask problem [Jan. 21st, 2006|02:06 pm]
LiveJournal Client Discussions
I am using XML-RPC postevent and want to post to either all friends or a specific custom friends group.

Having read the postevent docs

[scalar](required) Specifies who can read this post. Valid values are public (default), private and usemask. When value is usemask, viewability is controlled by the allowmask.

[scalar](required) Relevant when security is usemask. A 32-bit unsigned integer representing which of the user's groups of friends are allowed to view this post. Turn bit 0 on to allow any defined friend to read it. Otherwise, turn bit 1-30 on for every friend group that should be allowed to read it. Bit 31 is reserved.

I assumed I just had to send 0 for all friends and 1 for the first friend group, 2 for the second friend group and so on. But I am clearly misunderstanding the allowmask.

If I send


LJ shows the post with the security set to 'custom' but no specified groups (so in fact no-one but me can see it).

While if I send


LJ shows the post with security set to friends only, not just group 1.

Can anyone explain what I should be doing?

[User Picture]From: int
2006-01-22 02:09 am (UTC)
Turning bit 0 on would give you 00000001, which is equal to 1, which is what you set for friends-only. Sending 0 sets it to custom with no groups set to view it, which is pretty much equal to making a private post (I think).

So if you wanted to make a custom post with friends groups 2 and 4 set to be able to view it, you'd send the number 00010100 as an integer (which would be 20). It's a weird system, and I don't know why they decided to go with this, but that's how it is. *shrugs*
(Reply) (Thread)
From: peasant_
2006-01-22 10:38 am (UTC)
Thank you. I had never even heard of the concept of a bit before today but with the aid of googling most of the words and more thought than I care for on a Sunday morning I think I understand.

(For the benefit of anyone who follows in my confused footsteps this explanation is very helpful: Bitwise Operators in C.)

Just to clarify, I actually send the decimal number, not the binary, right?

So now all I have to do is programme it. Joy.
(Reply) (Parent) (Thread)
[User Picture]From: int
2006-01-22 10:52 am (UTC)
Yep, that's right. Here's how I did it in JavaScript if you're interested.
(Reply) (Parent) (Thread)