我是新來的Twitter與我的Android應用程序集成。我必須在Twitter上發佈圖片和視頻。我成功地能夠使用Twitpic在Twitter上發佈圖片,但沒有發現在Twitter上發佈視頻的任何線索。在Twitter上上傳視頻
請幫助我,與相關鏈接或建議我做一樣的方法。
Sry基因的問這樣一個直接的問題,沒有任何一段代碼..
我是新來的Twitter與我的Android應用程序集成。我必須在Twitter上發佈圖片和視頻。我成功地能夠使用Twitpic在Twitter上發佈圖片,但沒有發現在Twitter上發佈視頻的任何線索。在Twitter上上傳視頻
請幫助我,與相關鏈接或建議我做一樣的方法。
Sry基因的問這樣一個直接的問題,沒有任何一段代碼..
您可以在TwitPic上載媒體。此代碼適用於圖片,但以相同的方式您也可以上傳視頻。
class ImageSender extends AsyncTask<URL, Integer, Long> {
private String url;
protected void onPreExecute() {
//mProgressDialog = ProgressDialog.show(SendImageActivity.this, "", "Sending image...", true);
//mProgressDialog.setCancelable(false);
//mProgressDialog.show();
}
protected Long doInBackground(URL... urls) {
long result = 0;
// TwitterSession twitterSession = new TwitterSession(SendImageActivity.this);
AccessToken accessToken = getAccessToken();
Configuration conf = new ConfigurationBuilder()
.setOAuthConsumerKey(Constants.CONSUMER_KEY)
.setOAuthConsumerSecret(Constants.CONSUMER_SECRET)
.setOAuthAccessToken(mToken)
.setOAuthAccessTokenSecret(mSecreat)
.build();
OAuthAuthorization auth = new OAuthAuthorization (conf, conf.getOAuthConsumerKey(), conf.getOAuthConsumerSecret(),
new AccessToken (conf.getOAuthAccessToken(), conf.getOAuthAccessTokenSecret()));
ImageUpload upload = ImageUpload.getTwitpicUploader ("8d012dd3948af2cdc42f93859908a717", auth);
Log.d(TAG, "Start sending image...");
try {
url = upload.upload(new File(imagePath));
result = 1;
Log.d(TAG, "Image uploaded, Twitpic url is " + url);
} catch (Exception e) {
Log.e(TAG, "Failed to send image");
e.printStackTrace();
}
return result;
}
protected void onProgressUpdate(Integer... progress) {
}
protected void onPostExecute(Long result) {
//mProgressDialog.cancel();
String text = (result == 1) ? "Image sent successfully.\n Twitpic url is: " + url : "Failed to send image";
System.out.println("Twitter Image==========="+text);
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_LONG).show();
}
}
public AccessToken getAccessToken() {
String token = mToken;
String tokenSecret = mSecreat;
if (token != null && tokenSecret != null)
return new AccessToken(token, tokenSecret);
else
return null;
}
不要忘了先登錄代碼並使用庫(罐子)。
你好@gaurav阿羅拉我想鳴叫圖像給想法或代碼,以完成任務,在此先感謝 – 2015-06-22 12:41:53