Hello,
I’m trying the API version1.1 using TWRequest on iOS5.
Only if I call “GET users/lookup” API, received the following authenticate error.
<Send>
GET https://api.twitter.com/1.1/users/lookup.json?user_id=xxx,yyy,zzz&include_entities=true
<Receive>
errors = (
{
code = 32;
message = "Could not authenticate you";
}
);
But if I call other API, e.g. friendships/create, in the same way(use the same source code except URL), it worked correctly!!
How can I avoid this error? I have no idea how should I do.
Anyone else with same situation or investigate it?
Thanks in advance.
episod
#2
Thanks for the report. Do you know how the commas are getting encoded when executing the request this way? Have you tried a POST request? TWRequest may expect you to prepare your request with %2C on the query string for commas instead.
v1.1’s OAuth is a bit stricter over all, though it should actually be pretty lenient around comma use.
Thanks, Taylor.
The commas were not encoded as you indicated and fixed the code as following, it worked!
Thank you for your quick reply and kindness.
NSString *url_str_enc = (NSString *)CFURLCreateStringByAddingPercentEscapes(
kCFAllocatorDefault,
(CFStringRef)url_str,
NULL,
CFSTR(“,”),
kCFStringEncodingUTF8
);
NSURL *url = [NSURL URLWithString:url_str_enc];
TWRequest *request = [[TWRequest alloc] initWithURL:url parameters:nil
requestMethod:TWRequestMethodGET];
we tried the similar approach for,
http://api.twitter.com/1.1/users/show.json
in our code its return,
errors = (
{
code = 215;
message = “Bad Authentication data”;
}
);
pls help to resolve.