아래의 간단한 코드를 사용하여 내 사용자의 트위터 상태를 업데이트하고 있습니다. 내 문제는이 코드의 결과 인 Twitter 업데이트가 "from API"으로 표시된다는 것입니다. 사용자 정의 이름을 말하기 위해 "API"부분을 제어 할 수 있기를 원합니다. 내가 어떻게 해? 제임스 데블린에 의해 Coding the Tweet : 바람직트위터 상태 업데이트 : 소스 설정 (C#)
감사
/*
* A function to post an update to Twitter programmatically
* Author: Danny Battison
* Contact: [email protected]
*/
/// <summary>
/// Post an update to a Twitter acount
/// </summary>
/// <param name="username">The username of the account</param>
/// <param name="password">The password of the account</param>
/// <param name="tweet">The status to post</param>
public static void PostTweet(string username, string password, string tweet)
{
try
{
// encode the username/password
string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
// determine what we want to upload as a status
byte[] bytes = System.Text.Encoding.ASCII.GetBytes("status=" + tweet);
// connect with the update page
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/update.xml");
// set the method to POST
request.Method = "POST";
request.ServicePoint.Expect100Continue = false; // thanks to argodev for this recent change!
// set the authorisation levels
request.Headers.Add("Authorization", "Basic " + user);
request.ContentType = "application/x-www-form-urlencoded";
// set the length of the content
request.ContentLength = bytes.Length;
// set up the stream
Stream reqStream = request.GetRequestStream();
// write to the stream
reqStream.Write(bytes, 0, bytes.Length);
// close the stream
reqStream.Close();
}
catch (Exception ex)
{
// Log the error
}
}
REST API를 사용하는 것이 불가능한 것 같습니다. 나는 여전히 그것을 찾고 cURL 커맨드 라인을 사용하여 테스트하고 있지만, 안되는 것은 작동하지 않는다. –