API questions

44 views
Skip to first unread message

gordong

unread,
Jun 17, 2011, 6:19:22 PM6/17/11
to PBworks API
Hi pbworks API developers,
I'm Gordon, an education technology developer. I am new to pbworks'
api, and I have a lot of questions that I hope you can help me with.

1. I see in the API calls are organized by Contexts and I'm not really
sure what those mean except that different pbworks.com accounts have
access to different contexts. For example, I read that Classroom
accounts (which I am using for testing) can only access the Wiki
context API calls. But there is also an "Any" context that seems, and
calls to that seem to work.

2. is it possible to set folder permissions (group access) via the
API? I don't see any calls. There is a "setFilePermissions" (though
the user manual it states it is not possible to set permissions on a
"file") and there is a SetPageUserPermission, but nothing I can find
that would set Folder permissions.

3. is it possible to assign groups to users via the API? I can't seem
to find an API call that allows that.

3.b. If the 3 is possible, then we would be able to assign multiple
groups to users? - I see the user info returned by the API call
GetUserInfo shows the group assignment is represented in an array,
implying a user can belong to multiple groups...

4. GetPages - I am using javascript and ajax to load and access data
returned by the API calls. I note that using GetPages, the returns and
object that contains a "pages" "array" (technically it is not a
javascript array object). In trying to iterate through pages, for
example: with a for( var i in pages ), it appears there are many more
elements in the pages array than the _total_count field denotes. It
looks like the pages array also contains elements that are function
pointers, and which are not visible in the returned text data. What
is going on there - is evalJSON(), which I use to transform the
returned text into a javascript object, not parsing what is returned
by GetPages properly? (it looks like the javascript object returned by
evalJSON() over steps its bounds, an perhaps what is returned by
GetPages is not closed properly.) I use the exact same code to load,
parse, and iterate through the folders array returned by GetFolders
and this problem does not occur.

Well, that's a lot for now! Thanks for your help with these
questions!
Gordon

Eileen Xie

unread,
Jun 20, 2011, 2:18:45 PM6/20/11
to PBworks API
> 1. I see in the API calls are organized by Contexts and I'm not really
> sure what those mean except that different pbworks.com accounts have
> access to different contexts.  For example, I read that Classroom
> accounts (which I am using for testing) can only access the Wiki
> context API calls.  But there is also an "Any" context that seems, and
> calls to that seem to work.

Context is the workspace or network that you are making calls against.
All of our products contain at least one workspace (aka wiki). Our
business product comes with a network, which spans across multiple
workspaces. "Any" context means that API can be called against either
a workspace or a network. "None" context means the API doesn't apply
to a network or workspace, so you would call them against
plans.pbworks.com.

> 2. is it possible to set folder permissions (group access) via the
> API?   I don't see any calls.  There is a "setFilePermissions" (though
> the user manual it states it is not possible to set permissions on a
> "file") and there is a SetPageUserPermission, but nothing I can find
> that would set Folder permissions.

We have the SetFolderUserPermission and SetFolderGroupPermission API
calls, but they are not available in all our packages, so they do not
appear in our general documentation. For workspaces that have access
to these calls (such as Classroom accounts), you can view their
documentation at:

http://WORKSPACENAME.pbworks.com/api_v2/op/DescribeOp/desc/SetFolderUserPermission
http://WORKSPACENAME.pbworks.com/api_v2/op/DescribeOp/desc/SetFolderGroupPermission

> 3. is it possible to assign groups to users via the API? I can't seem
> to find an API call that allows that.

http://WORKSPACENAME.pbworks.com/api_v2/op/DescribeOp/desc/ReplaceWorkspaceGroupMembership

> 3.b.  If the 3 is possible, then we would be able to assign multiple
> groups to users? - I see the user info returned by the API call
> GetUserInfo shows the group assignment is represented in an array,
> implying a user can belong to multiple groups...

Users can be part of multiple network groups (available in our
business product), but only a single workspace group. See above
documentation.

> 4. GetPages - I am using javascript and ajax to load and access data
> returned by the API calls. I note that using GetPages, the returns and
> object that contains a "pages" "array" (technically it is not a
> javascript array object).  In trying to iterate through  pages, for
> example: with a for( var i in pages ), it appears there are many more
> elements in the pages array than the _total_count field denotes. It
> looks like the pages array also contains elements that are function
> pointers, and which are not visible in the returned text data.   What
> is going on there - is evalJSON(), which I use to transform the
> returned text into a javascript object, not parsing what is returned
> by GetPages properly? (it looks like the javascript object returned by
> evalJSON() over steps its bounds, an perhaps what is returned by
> GetPages is not closed properly.)  I use the exact same code to load,
> parse, and iterate through the folders array returned by GetFolders
> and this problem does not occur.

If anything, _total_count should be greater than the number of
elements in the pages array, not the other way around. For example, if
you want to return 10 pages at a time, the pages array will only
contain 10 pages, whereas _total_count will contain the total number
of pages visible to you.

You said you're using evalJSON(), which means you're using Prototype.
The extra things at the end are being inserted by Prototype, and are
what allow you to do things like "some string".evalJSON(). If you
inspect the actual response text, you'll find those things aren't
coming from us. See Prototype's documentation for how to deal with
their arrays: http://www.prototypejs.org/api/array

- Eileen Xie

gordong

unread,
Jun 20, 2011, 2:53:51 PM6/20/11
to PBworks API
Thank you so much, Elieen! This helps immensely!

I'm sure I will have more quesitons in the future.

Cheers,
Gordon

(by the way, Eileen is also my sisters name!)

Reply all
Reply to author
Forward
0 new messages