Twitter Api

2008-12-05 Thread anas

Hi all,

Im working on ROR application.

Im using twitterAPI.

Im trying for retrieving followers of mine.

Please explain me in deatail about this and  how to retrieve user
image and status in my Application





with regards:
ANAS( developer INNOZON hyderabad).


Update profile image

2008-12-05 Thread Sean

I have been trying for a while to get the update_profile_image method
to work without much luck.  I have been able to successfully call
several other methods including ./friendships/create/ and account/
verify_credentials.xml, but have been having trouble with this method.

The exception returned is: The remote server returned an error: (403)
Forbidden.
And the status on the exception is: ProtocolError

I have verified that the image I am trying to upload will upload using
the settings page on my Twitter account.  It is a 30x30 jpg.

I am using c# and the HttpWebRequest class.  I am sure there is a
problem with how I am generating the multi-part form data because if I
change the name of the image parameter I get the same message which
I think means the service can't parse the request data the way I am
sending it.

Code is below along with the error message and response object I get
back from the server.  If anyone has any ideas about what I am doing
wrong I would really appreciate the help.  Thanks.

Code:
private void UploadFile(string filename)
{
string url = @http://twitter.com/account/
update_profile_image.xml;

HttpWebRequest request = (HttpWebRequest)WebRequest.Create
(url);

string boundary = 7d72b92a170f1a;
string headerBoundary = --7d72b92a170f1a;  //
two dashes less than boundary
string newline = \r\n;

request.ContentType = multipart/form-data; boundary= +
headerBoundary;
request.Method = POST;

MemoryStream data = new MemoryStream();
StreamWriter sw = new StreamWriter(data);
sw.Write(boundary + newline);

// Write file to data
sw.Write(Content-Disposition: form-data; name=\image\;
image=\{0}\{1}, filename, newline);
sw.Flush();

byte[] file = File.ReadAllBytes(filename);
data.Write(file, 0, file.Length);

sw.Write(newline);
sw.Write(newline);

sw.Write({0}--{1}, boundary, newline);
sw.Flush();

// write data to request
request.ContentLength = data.Length;
request.Headers.Add(Authorization, Basic  +
System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes
(username:password)));
using (Stream s = request.GetRequestStream())
{
data.WriteTo(s);
}
data.Close();

try
{
// use the request object to get to the response
WebResponse response = request.GetResponse();

if (response != null)
{
StreamReader sr = new StreamReader
(response.GetResponseStream());
string result = sr.ReadToEnd();
}
}
catch (WebException exception)
{
HttpWebResponse httpResponse = (HttpWebResponse)
exception.Response;

}
}


Exception and response details:

CharacterSetutf-8
ContentEncoding
ContentLength   183
ContentType application/xml; charset=utf-8
Cookies {System.Net.CookieCollection}
Headers {Status: 403 Forbidden
Pragma: no-cache
Vary: Accept-Encoding
Connection: close
Content-Length: 183
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-
check=0
Content-Type: application/xml; charset=utf-8
Date: Fri, 05 Dec 2008 15:26:28 GMT
Expires: Tue, 31 Mar 1981 05:00:00 GMT
Last-Modified: Fri, 05 Dec 2008 15:26:28 GMT
Set-Cookie:
_twitter_sess=BAh7BzoHaWQiJTgxZmIyODE1ZjY3MGI3YjRiOGE1MmFkODJmNjhlOGQwIgpm
%250AbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAG
%250AOgpAdXNlZHsA--b336ca8846bc144106c5160724c82d54b2bfe824;
domain=.twitter.com; path=/
Server: hi

System.Net.WebHeaderCollection
IsMutuallyAuthenticated FALSE
LastModified{12/5/2008 9:26:28 AM}
Method  POST
ProtocolVersion {1.1}
ResponseUri {http://twitter.com/account/update_profile_image.xml}
Server  hi
StatusCode  Forbidden
StatusDescription   Forbidden

ExceptionStatus ProtocolError





Re: API versus Live Site discrepancy

2008-12-05 Thread Greg Schoen

Were those changes pushed live? I'm still seeing that user.

Alex Payne wrote:
 Actually, we're just pushing out changes today that excise suspended
 users from API responses.  Sorry for the confusion there.

 On Thu, Dec 4, 2008 at 12:32, Greg Schoen [EMAIL PROTECTED] wrote:
 
  Is it possible to poll the API for a user's suspended status?
 
  I am pulling up the show.xml for a suspended user, and nothing on that
  page leads me to believe that the account has been suspended. The xml
  document would have you believe that nothing is wrong with the
  account, that everything is live. However, trying to access their page
  directly results in the Suspension message.
 
  This is a difficult issue because my hourly API calls are being used
  up by polling users that are no longer valid, and nothing in their
  response leads me to believe this. I could totally bypass the API and
  screen scrape the data, but I'm sure that's not looked very highly on,
  and it would defeat the purpose of having the API.
 
  So am I missing something, or is this feature not out there?
 
  Example:
  user: bellyloss
  http://twitter.com/users/show/bellyloss.xml returns user data
  http://twitter.com/bellyloss returns the /suspended page
 



 --
 Alex Payne - API Lead, Twitter, Inc.
 http://twitter.com/al3x