Error when: createFriendship (Only unicode objects are escapable.) #121

Closed
opened 2012-10-09 13:01:27 -07:00 by MarcosRamirez · 8 comments
MarcosRamirez commented 2012-10-09 13:01:27 -07:00 (Migrated from github.com)

I get a strange error when i try to add a follow:

twitter.createFriendship(id=task['target'],follow=True)
errorHandler: Unmanaged error detected when Following: XXXX: Only unicode objects are escapable.

XXXX is the twitter id of the user (a long), contained in task['target'], so... no unicode posible :¿

I check is on createFriendShip, when i do the oauth, i get no error.

I'm absolutely lost... any help will be appreciated:

Additional info (tell me if need more)

Python 2.7.3
twython-2.4.0.tar.gz
Ubuntu 12.04.1 LTS

I get a strange error when i try to add a follow: twitter.createFriendship(id=task['target'],follow=True) errorHandler: Unmanaged error detected when Following: XXXX: Only unicode objects are escapable. XXXX is the twitter id of the user (a long), contained in task['target'], so... no unicode posible :¿ I check is on createFriendShip, when i do the oauth, i get no error. I'm absolutely lost... any help will be appreciated: Additional info (tell me if need more) Python 2.7.3 twython-2.4.0.tar.gz Ubuntu 12.04.1 LTS
michaelhelmick commented 2012-10-09 13:11:32 -07:00 (Migrated from github.com)

Try:

twitter.createFriendship(user_id=task['target'],follow=True)

Keyword arg user_id instead of just id

Try: ``` python twitter.createFriendship(user_id=task['target'],follow=True) ``` Keyword arg `user_id` instead of just `id`
MarcosRamirez commented 2012-10-10 00:56:47 -07:00 (Migrated from github.com)

Same result ;(

Same result ;(
MarcosRamirez commented 2012-10-10 01:16:32 -07:00 (Migrated from github.com)

Also tried:

sc='ValidOne'
twitter.createFriendship(screen_name=sc,follow=True)
twitter.createFriendship(screen_name=sc.encode('UTF-8'),follow=True)

And i keep getting the "Only unicode objects are escapable." error

Really confusing for me.

Also tried: sc='ValidOne' twitter.createFriendship(screen_name=sc,follow=True) twitter.createFriendship(screen_name=sc.encode('UTF-8'),follow=True) And i keep getting the "Only unicode objects are escapable." error Really confusing for me.
MarcosRamirez commented 2012-10-10 02:53:29 -07:00 (Migrated from github.com)

Another try, I guess he expects for an unicode value, so, i ensure:

twitter.createFriendship(user_id=unicode(str(task['target'])),follow=True)

But, no luck...

Another try, I guess he expects for an unicode value, so, i ensure: twitter.createFriendship(user_id=unicode(str(task['target'])),follow=True) But, no luck...
michaelhelmick commented 2012-10-10 07:25:13 -07:00 (Migrated from github.com)

Can you provide the full stack trace please?

Can you provide the full stack trace please?
michaelhelmick commented 2012-10-10 10:03:56 -07:00 (Migrated from github.com)

Alright, don't worry about providing the stack trace. The issue comes where follow=True. requests doesn't like that. I'm working on a fix now.

Alright, don't worry about providing the stack trace. The issue comes where `follow=True`. `requests` doesn't like that. I'm working on a fix now.
michaelhelmick commented 2012-10-10 10:22:38 -07:00 (Migrated from github.com)

Alright, got it.

You need to do this:

twitter.createFriendship(user_id=task['target'],follow='True')

requests doesn't like items that can't be converted to unicode and rightfully so.
So just pass True as a string instead. I just ran the code and it works for me: Follows the target user and turns on mobile notifications. However note: That the authenticated user MUST have a phone number associated with the account or else notifications will not be turned on. The friendship will still be created, they just won't receive notifications because well... they can't. Haha.

@ryanmcgrath You can close this. :)

Alright, got it. You need to do this: ``` python twitter.createFriendship(user_id=task['target'],follow='True') ``` `requests` doesn't like items that can't be converted to unicode and rightfully so. So just pass `True` as a string instead. I just ran the code and it works for me: Follows the target user and turns on mobile notifications. **However** _note:_ That the authenticated user MUST have a phone number associated with the account or else notifications will not be turned on. The friendship will still be created, they just won't receive notifications because well... they can't. Haha. @ryanmcgrath You can close this. :)
MarcosRamirez commented 2012-10-12 09:21:22 -07:00 (Migrated from github.com)

Great!! thanks a lot...

Great!! thanks a lot...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: code/twython#121
No description provided.