如果不是必需的,你需要使用imgur
,那么我建议你尝试yfrog
。
例子
抱歉,我没有时间编写 C# 示例,但这里是 PHP 示例:(源链接)
<?php
/**
* This example demonstrates how to use OAuth credentials of your application to upload data to yfrog
* Usage: upload-to-yfrog-example.php <FILENAME-TO-UPLOAD>
*/
// TODO: PUT YOUR KEYS HERE
// your app's OAuth consumer & secret
define('OAUTH_CONSUMER_KEY', '');
define('OAUTH_CONSUMER_SECRET', '');
// your app user's token and secret, when twitter user granted access to your app
define('OAUTH_TOKEN_KEY', '');
define('OAUTH_TOKEN_SECRET', '');
// END OF TODO
// you can grab required file here:
// http://github.com/abraham/twitteroauth
require_once('OAuth.php');
// instantiating OAuth customer
$consumer = new OAuthConsumer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
// instantiating signer
$sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
// user's token
$token = new OAuthConsumer(OAUTH_TOKEN_KEY, OAUTH_TOKEN_SECRET);
// signing URL
$url = 'https://twitter.com/account/verify_credentials.xml';
$request = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $url, array());
$request->sign_request($sha1_method, $consumer, $token);
$url = $request->to_url();
// OK, URL is signed, we can pass it to yfrog API
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://yfrog.com/api/upload');
$post = array
(
'username' => 'yfrogtests', // twitter's username
'verify_url' => $url, // signed URL
'media' => '@' . $argv[1], // filename
'auth' => 'oauth', // auth=oauth is mandatory to use verify_url method
'message' => 'see it live on yfrog' // message to be sent, will not be posted to twitter
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close ($ch);
echo $response;
// see http://twitter.com/yfrogtests
?>
编辑:
正常流程规定应用程序将请求令牌发送到 Twitter 的 OAuth 规范实现中的 oauth/authorize。

访问令牌持续多长时间?
我们目前不会使访问令牌过期。如果用户从他们的设置中明确拒绝您的应用程序,或者如果 Twitter 管理员暂停您的应用程序,您的访问令牌将无效。如果您的申请被暂停,您的申请页面上将会有一条说明,说明它已被暂停。
来源:http ://dev.twitter.com/doc
您需要拥有访问令牌并获得它,用户需要首先批准您的应用程序 - 没有办法解决这个问题。
此外,您的应用程序可以对 1 个帐户进行的(写入)访问次数限制为每天约 300 次。因此,除非您的程序是为 1-3 人设计的,否则您将达到该限制。我的结论是:用户需要是提供身份验证的人。