What am I missing, this seems simple...

37 views
Skip to first unread message

DrBigFresh

unread,
Dec 2, 2010, 4:55:59 PM12/2/10
to Posterous development
So I'm trying to move over to the new 2.0 API. I have my apiKey, but I
don't see anyway to get the ID of a user--even when I have their login
info? I see that I can get my own using the '/me' but how do I know
authenticate a different user and get their ID? Do I have to use the
1.0 API for this?

Christopher Burnett

unread,
Dec 2, 2010, 5:48:16 PM12/2/10
to poster...@googlegroups.com

If you have a users login credentials then the 'me' keyword can be used and their id.

example:

curl --user so...@user.com:password http://posterous.com/api/2/users/me?api_token=<your token>

Returns:

  "firstname" :'Chris',
  "id" : 110,
  "last_activity" : "2010/12/01 20:46:49 -0800",
  "lastname" :'Burnett',
  "nickname" : "twoism",
  "profile_pic" : "/images/profile/unknown75.gif",
  "sites" : [ { "comment_permission" : 1,
        "full_hostname" : "siteone.posterdev.local",
        "id" : 166,
        "is_private" : false,
        "name" : "User One's posterous",
        "posts_count" : 180,
        "token" : "EwHHItvtjJkjcowgzqtmEFanlwvJFipC"
      }
    ]
}

-- 
Christopher Burnett
--
You received this message because you are subscribed to the Google Groups "Posterous development" group.
To post to this group, send email to poster...@googlegroups.com.
To unsubscribe from this group, send email to posterous-de...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/posterous-dev?hl=en.

DrBigFresh

unread,
Dec 2, 2010, 6:20:28 PM12/2/10
to Posterous development
Strange. If I run that on the command line, with the correct data, I
get no response.

If I run it (using CURL) in my php app, I get the following response:
[response] => {"error":"Invalid Request","message":"Did you forget the
_method param?"}


On Dec 2, 2:48 pm, Christopher Burnett <signalsta...@gmail.com> wrote:
>  If you have a users login credentials then the 'me' keyword can be used and their id.
>
> example:
>
> curl --user s...@user.com:passwordhttp://posterous.com/api/2/users/me?api_token=<your token>

DrBigFresh

unread,
Dec 2, 2010, 6:40:05 PM12/2/10
to Posterous development
Now it's giving me the correct response via the command line, but I'm
still getting the 'Did you forget the
_method param?' if I do it via curl in php. I see in the docs this:
HTTP methods are specified by a _method param with the corresponding
HTTP verb.

But I'm not following what the _method should be set to?

DrBigFresh

unread,
Dec 2, 2010, 6:57:25 PM12/2/10
to Posterous development
Never mind, got it. Setting _method to 'GET' fixed it.

Christopher Burnett

unread,
Dec 2, 2010, 6:45:21 PM12/2/10
to poster...@googlegroups.com

_method is used to specify the HTTP verb. In your case it should be 'GET'.

With CURL in php you should be able to specify that this is a GET request though without having to send the param.

--chris

On Thursday, December 2, 2010 at 3:40 PM, DrBigFresh wrote:

Now it's giving me the correct response via the command line, but I'm
still getting the 'Did you forget the
_method param?' if I do it via curl in php. I see in the docs this:
HTTP methods are specified by a _method param with the corresponding
HTTP verb.

But I'm not following what the _method should be set to?


On Dec 2, 3:20 pm, DrBigFresh <drbigfr...@gmail.com> wrote:
Strange. If I run that on the command line, with the correct data, I
get no response.

If I run it (using CURL) in my php app, I get the following response:
[response] => {"error":"Invalid Request","message":"Did you forget the
_method param?"}

On Dec 2, 2:48 pm, Christopher Burnett wrote:

>  If you have a users login credentials then the 'me' keyword can be used and their id.

> example:

> curl --user s...@user.com:passwordhttp://posterous.com/api/2/users/me?api_token=

Keith

unread,
Dec 28, 2010, 2:15:57 PM12/28/10
to Posterous development
So what do we do if we don't have the user's credentials but we still
want to know the user_id associated with their account? The reason I
ask is because I want to be able to retrieve the public posts for a
site that is not my own.

If I do something like : http://posterous.com/api/2/users/me/sites/blog/posts/public
to attempt to read from blog.posterous.com I get a blank response.
If I change it to: http://posterous.com/api/2/users/1/sites/blog/posts/public
I get the expected JSON response with the recent posts.

I assume this is the case because specifying "me" will use my user_id
and thus block me access from reading the public posts from blog,
while "1" must be the id of an author of "blog" and therefore the API
lets me read the posts.

Based off this and other tests I've made, it seems that I can only get
posts for a site where the user_id specified is that of an author of
the site. If that's the case, how can I get the user_id of another
user without their credentials?

Or if that's not possible, what is the correct way for me to get posts
for another user's site?


Thanks for any insight,

keith

On Dec 2, 3:45 pm, Christopher Burnett <ch...@posterous-inc.com>
wrote:
> > > ....@gmail.com>
Reply all
Reply to author
Forward
0 new messages