[twitter-dev] Re: C# + OAuth + account/update_profile_image = 500 Internal Server Error
You can use TwitterVB which covers nearly the complete API in .NET (OAuth included). U find it on codeplex http://twittervb.codeplex.com/ Cheers, Thomas Nicholas Granado schrieb: Simon, You would sign the request with all of the usual oauth param suspects. If I recall correctly this endpoint has no other params other than the 'image' param in the multi-part post body whose value would be the bytes of the image file. Typically I've only seen the post params passed into the oauth signing rigmarole when the post body is urlencoded. I hope this helps, this whole OAuth thing can be very confusing at first glance. If you are in C# I have my own lib for twitter basic auth/oauth that I've baked up, if you like I could pass you the bits. Nicholas --- Nicholas Granado email: ngran...@gmail.com mailto:ngran...@gmail.com twitter: heatxsink web:http://nickgranado.com On Mon, Oct 19, 2009 at 6:38 AM, Zaudio si...@z-audio.co.uk mailto:si...@z-audio.co.uk wrote: Nicholas, That's great feedback! In you opinion, how do I then sign the request? Do I use all the usual for the signaturebase... ie postmethodurlnonceetc etc or just postmethodurl as David suggested? I trust that the image data does not come into the signing process, and that I still can post the data using iso-8859-1 encoding as I would normally do for uploading files? If you have these answers, then I should be able to nail this for our .net case.Oauth's been working great for us until this hitch... Thanks Simon On Oct 18, 6:11 pm, Nicholas Granado ngran...@gmail.com mailto:ngran...@gmail.com wrote: Simon, I believe the body of your post might be incorrect. It should look like this: POST /account/update_profile_image.xml HTTP/1.1 Content-Type: multipart/form-data; boundary=8cbed79c91b24f3 Host: twitter.com http://twitter.com Content-Length: 3863(this will probably change now..) --8cbed79c91b24f3 Content-Disposition: form-data; name=image; filename=test.jpg Content-Type: image/jpeg (there's a few K of binary data here, the contents of the file) --8cbed79c91b24f3 The rest of the OAuth variables should be passed on the query string. I hope this helps. Cheers, Nicholas --- Nicholas Granado email: ngran...@gmail.com mailto:ngran...@gmail.com twitter: heatxsink web:http://nickgranado.com On Sun, Oct 18, 2009 at 2:42 PM, Zaudio si...@z-audio.co.uk mailto:si...@z-audio.co.uk wrote: Hi David, I found your excellent post hoping that it would solve the same challenge for my app: updating profile image via Oauth... using similar .net base to yourself... BUT I just get the 401 all the time... despite taking your advice to just sign with the HTTPmethod URL My post data is laid out much like yours... though I never got that 500 error... I've tried all sorts... dropping the off the end different encodings... What encoding did you use to encode your image, and then to post the request? Does it still work for you... or did this get broken when Twitter 'fixed' their Oauth implementation? Can anyone else advise if they have got this working and where I might be going wrong? Thanks Simon (Zaudio) On Aug 19, 11:40 pm, David Carson carson63...@gmail.com mailto:carson63...@gmail.com wrote: Got this sorted out and working, and thought I should share the two pitfalls which were causing me problems. First of all, unbelievably, the 500 Internal Server Error was being caused by an extra carriage return between my last HTTP header and the first multipart boundary. Seriously. I had two blank lines in there instead of one. Removed the extra carriage return, and my 500 vanished, being replaced by a more reasonable (401) Unauthorized - Incorrect signature error. Secondly, the OAuth documentation seems a bit shaky when it comes to multipart/form-data POSTs. But basically, you do NOT use any of the POST parameters when creating your signature. And this includes all of the OAuth-specific parameters like oauth_consumer_key, oauth_signature_method, etc. Bit of a security hole imho, OAuth implements all this complexity to avoid man-in-the-middle or replay attacks, and as soon as you do a multipart POST it's all negated. So, my signature base was literally:
[twitter-dev] Re: How to check if user is followed?
I only can talk for .NET - A Dictionary(of Long, Boolean) with 5000 Id's needs around 500 Ticks If I request the Method .ContainsKey. I don't think that an API Request with parsing xml can be faster. Additional you nail the server with unneeded requests which are expensive (rate limits) too I don't know your Applicaton but you'll handle all accounts at the same time? Normaly if an user authenticates the first calls could be to request the ID Lists and store them during this users sessiontime. If a user leaves you can free this memory. On 5 Okt., 12:03, twittme_mobi nlupa...@googlemail.com wrote: Hi Tomas, another question to collaborate, do you think that is faster to find the ID in array by iterating it rather that searching for a string in the XML with some well known search function On Oct 5, 10:54 am, twittme_mobi nlupa...@googlemail.com wrote: Hi Tomas, Thanks for the clarification. One question - if you have many users, you will need to load all the IDs for All the users in the memory - isn't that too heavy?some of the users have 10+ followers. Thanks. On Oct 4, 6:26 pm, Thomas Hübner thueb...@gmx.de wrote: the problem is that a friendship exist is an expensive API Call (of 150 possible per hr) I do not know what kind of Application you plan but for my client App I load the ID's of followers with one API call and keep this list in memory. If a status become loaded I compare the icluded UserID with the list and switch the menues depending on containing this ID or not. This is much faster then request the API each time. Only situation which is not working for are search calls because the delivered result (ATOM) does not contain any userID which is a fail twittme_mobi schrieb: Hi Tomas, thanks for the reply! the social graph methods are too heavy for such a simple operation. I have to check if user is followed every time that a profile is visited so i would now where to put Follow or Unfollow button.It is not reasonable to execute the social graph methods every time, because sometimes users might have thousands of followers.Isn't it the friendship/exists method that needs to be fixed, after all, it is just for checking if user is followed or not.. Thanks!Your opinion is welcome! On Oct 3, 2:20 pm, Thomas Hübner thueb...@gmx.de wrote: you have the social graph methods which deliver ID's. Unfortunately the same API call for screennames is missed - so you never can make comparings with search API results because there is no userID in. friends/ids followers/ids cheers, Thomas twittme_mobi schrieb: Hi guys, i tried friendship/exists but it throws an error when the user is protected.How should i accomplish this task with the API? signature.asc 1KViewDownload signature.asc 1KViewDownload
[twitter-dev] Re: How to check if user is followed?
the problem is that a friendship exist is an expensive API Call (of 150 possible per hr) I do not know what kind of Application you plan but for my client App I load the ID's of followers with one API call and keep this list in memory. If a status become loaded I compare the icluded UserID with the list and switch the menues depending on containing this ID or not. This is much faster then request the API each time. Only situation which is not working for are search calls because the delivered result (ATOM) does not contain any userID which is a fail twittme_mobi schrieb: Hi Tomas, thanks for the reply! the social graph methods are too heavy for such a simple operation. I have to check if user is followed every time that a profile is visited so i would now where to put Follow or Unfollow button.It is not reasonable to execute the social graph methods every time, because sometimes users might have thousands of followers.Isn't it the friendship/exists method that needs to be fixed, after all, it is just for checking if user is followed or not.. Thanks!Your opinion is welcome! On Oct 3, 2:20 pm, Thomas Hübner thueb...@gmx.de wrote: you have the social graph methods which deliver ID's. Unfortunately the same API call for screennames is missed - so you never can make comparings with search API results because there is no userID in. friends/ids followers/ids cheers, Thomas twittme_mobi schrieb: Hi guys, i tried friendship/exists but it throws an error when the user is protected.How should i accomplish this task with the API? signature.asc 1KViewDownload signature.asc Description: OpenPGP digital signature
[twitter-dev] Re: Return number of pages (or number of friends/followers) on first call with cursor
the Number of ID's is the number of followers you also can call http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show first. Within the result you have followers_count1031/followers_count friends_count293/friends_count however - you have to do an additional API call if you don't trust the pagewise calls Jesse Stay schrieb: Thomas, I don't see where it gives you the expected number of users. Originally I thought Alex said that was going to be part of it, but not seeing it in the docs. I only see ids, next_cursor, and previous_cursor. On Sun, Oct 4, 2009 at 8:36 AM, Thomas Hübner thueb...@gmx.de mailto:thueb...@gmx.de wrote: You can use the socialGraph method before: http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-friends%C2%A0ids If you have this you have the expected number of users. Jesse Stay schrieb: I was wondering if it might be possible to include, at least in the first page, but if it's easier it could be on all pages, either a total expected number of followers/friends, or a total expected number of returned pages when the cursor parameter is provided for friends/ids and followers/ids? I'm assuming since you're moving to the cursor-based approach you ought to be able to accurately count this now since it's a snapshot of the data at that time. The reason I think that would be useful is that occasionally Twitter goes down or introduces code that could break this. This would enable us to be absolutely sure we've hit the end of the entire set. I guess another approach could also be to just list the last expected cursor ID in the set so we can be looking for that. Thanks, Jesse signature.asc Description: OpenPGP digital signature
[twitter-dev] Social Graph Methods followers/names ?
Hi All, would it be possible to get an additional API function which delivers the screennames instead of ID's? The reason is, I work on a Client App in .NET On Startup I load the followers, friends and blocked ID's. I use this to show the status then in my application and enable/ disable the menus with follow/ unfollw DM and so on. So I save expensive API calls (follow someone which I already follow) which ends in API Errors. So far so good. Now I try to implement the search API. This delivers me ATOM XML back. I Try to fill my status object and included User object with the less informations in delivered ATOM to show it in the same Quality like a User Timeline. Unfortunately the only thing I have in ATOM result is the screenname combined with username in one tag. No Problem I resolve that with RegEx. What urgently is missed is the user ID to compare it with the followers and friend list of ID's Now 2 solutions are possible: 1) adding the userID in the search results 2) offer an API call within social graph methods which delivers screennames In case of 2) I could use the unique screenname as Key. This would be a disadvantage because of searchroutines work always slower on string. Better soulution would be to delivers the userID within the searchresults. Is there any way to realize this? I do not think that I'm the only one ho miss this. Best regards, Thomas
[twitter-dev] Re: Twitter Client App Not Posting
If smthg. goes wrong you get an error back - in this very small XML Error document you have a XML node error. You should log the error and post it here On 29 Sep., 17:16, akademicjeanius enkwiringmi...@gmail.com wrote: Hello, I have a Twitter app that posts updates to Twitter every 5 minutes (274 times per day). About 8 times a day, the posts get rejected for some reason. I was wondering if this is a known problem with the Twitter API or more likely something to do with my app.
[twitter-dev] Re: Posting App name for posts
You have to register your App @ Twitter and user OAuth. If you use ASP.NET you maybe can use the TwitterVB Project (DLL) It includes the full OAuth Support. c_mcintosh schrieb: I have a site posting updates to twitter using the api. I can either have it say API or it says 'From Web', I am looking at getting my site url in the From... part of the post information. I have tried setting the source parameter to a href tag, the url to the site, and just a site name and all return From Web. Any ideas would be appreciated. signature.asc Description: OpenPGP digital signature
[twitter-dev] Re: Social Graph Methods followers/names ?
I would see this as second coice - userID in searchresults would be the better choice because a numeric comparing is in each case faster then string comparing Best would be to get both. From side of server (Database request) both things should be not to tricky to make. cheers, Thomas Nelu Lazar schrieb: I subscribe to this request. Usernames in social graph methods' responses could be useful for many other implementations. @NeluLazar Tweetvisor.com On Sep 29, 7:22 am, Thomas Hübner thueb...@gmx.de wrote: Hi All, would it be possible to get an additional API function which delivers the screennames instead of ID's? The reason is, I work on a Client App in .NET On Startup I load the followers, friends and blocked ID's. I use this to show the status then in my application and enable/ disable the menus with follow/ unfollw DM and so on. So I save expensive API calls (follow someone which I already follow) which ends in API Errors. So far so good. Now I try to implement the search API. This delivers me ATOM XML back. I Try to fill my status object and included User object with the less informations in delivered ATOM to show it in the same Quality like a User Timeline. Unfortunately the only thing I have in ATOM result is the screenname combined with username in one tag. No Problem I resolve that with RegEx. What urgently is missed is the user ID to compare it with the followers and friend list of ID's Now 2 solutions are possible: 1) adding the userID in the search results 2) offer an API call within social graph methods which delivers screennames In case of 2) I could use the unique screenname as Key. This would be a disadvantage because of searchroutines work always slower on string. Better soulution would be to delivers the userID within the searchresults. Is there any way to realize this? I do not think that I'm the only one ho miss this. Best regards, Thomas signature.asc Description: OpenPGP digital signature