本文整理汇总了Java中com.tumblr.jumblr.JumblrClient类的典型用法代码示例。如果您正苦于以下问题:Java JumblrClient类的具体用法?Java JumblrClient怎么用?Java JumblrClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JumblrClient类属于com.tumblr.jumblr包,在下文中一共展示了JumblrClient类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doInBackground
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
@Override
protected Boolean doInBackground(String... params) {
try {
//create authenticated client
JumblrClient client = new JumblrClient(params[0], params[1]);
client.setToken(params[2], params[3]);
//like post blog
client.like(Long.valueOf(params[4]), params[5]);
} catch (NumberFormatException e) {
e.printStackTrace();
return false;
}
//update liked post indicator, as we processed each photo of photoset as a different post, we have to check all photoPosts
for (int i = 0; i < photoPosts.size(); i++) {
if (photoPosts.get(i).getId().equals(Long.valueOf(params[4]))) {
//current photo belongs to the liked post
photoPosts.get(i).liked = true;
}
}
return true;
}
开发者ID:nioc,项目名称:tumblr-photo-browse,代码行数:24,代码来源:LikeBlogPost.java
示例2: doInBackground
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
@Override
protected Boolean doInBackground(String... params) {
try {
//create authenticated client
JumblrClient client = new JumblrClient(params[0], params[1]);
client.setToken(params[2], params[3]);
if (actionIsFollow) {
//follow blog
client.follow(params[4]);
toastedText = activity.getString(R.string.alert_blog_followed, params[4]);
} else {
//unfollow blog
client.unfollow(params[4]);
toastedText = activity.getString(R.string.alert_blog_unfollowed, params[4]);
}
} catch (Exception e) {
//catch error (mostly network issue)
exception = e;
return false;
}
return true;
}
开发者ID:nioc,项目名称:tumblr-photo-browse,代码行数:24,代码来源:FollowBlog.java
示例3: setup
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
@Before
public void setup() throws IOException {
Map<String, Object> flat = new HashMap<String, Object>();
flat.put("name", name);
flat.put("title", title);
flat.put("description", description);
flat.put("posts", posts);
flat.put("likes", likes);
flat.put("updated", updated);
flat.put("ask", ask);
flat.put("ask_anon", ask_anon);
flat.put("followers", followers);
Gson gson = new Gson();
blog = gson.fromJson(flatSerialize(flat), Blog.class);
blog.setName(blog.getName());
client = mock(JumblrClient.class);
blog.setClient(client);
}
开发者ID:tumblr,项目名称:jumblr,代码行数:20,代码来源:BlogTest.java
示例4: TumblrRetriever
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
public TumblrRetriever(Credentials credentials) throws Exception {
super(credentials);
if (credentials.getKey() == null || credentials.getSecret() == null) {
logger.error("Tumblr requires authentication.");
throw new Exception("Tumblr requires authentication.");
}
client = new JumblrClient(credentials.getKey(), credentials.getSecret());
}
开发者ID:MKLab-ITI,项目名称:simmo-stream-manager,代码行数:10,代码来源:TumblrRetriever.java
示例5: main
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, IOException, InstantiationException, IllegalAccessException {
// Read in the JSON data for the credentials
FileReader fr = new FileReader("credentials.json");
BufferedReader br = new BufferedReader(fr);
StringBuilder json = new StringBuilder();
try {
while (br.ready()) { json.append(br.readLine()); }
} finally {
br.close();
}
// Parse the credentials
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(json.toString());
// Create a client
JumblrClient client = new JumblrClient(
obj.getAsJsonPrimitive("consumer_key").getAsString(),
obj.getAsJsonPrimitive("consumer_secret").getAsString()
);
// Give it a token
client.setToken(
obj.getAsJsonPrimitive("oauth_token").getAsString(),
obj.getAsJsonPrimitive("oauth_token_secret").getAsString()
);
// Usage
List<Post> posts = client.blogPosts("seejohnrun");
for (Post post : posts) {
System.out.println(post.getShortUrl());
}
}
开发者ID:tumblr,项目名称:jumblr,代码行数:36,代码来源:App.java
示例6: testGetParams
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
@Test
public void testGetParams() {
JumblrClient client = new JumblrClient("abc", "def");
client.getRequestBuilder().setHostname("test.com");
Map<String, String> map = new HashMap<String, String>();
map.put("limit", "1");
OAuthRequest request = client.getRequestBuilder().constructGet("/path", map);
assertEquals(request.getUrl(), "https://test.com/v2/path");
assertEquals(request.getQueryStringParams().asFormUrlEncodedString(), "limit=1");
}
开发者ID:tumblr,项目名称:jumblr,代码行数:12,代码来源:RequestBuilderTest.java
示例7: doInBackground
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
protected List<UnitPhotoPost> doInBackground(String... params) {
List<UnitPhotoPost> photoPosts = new ArrayList<>();
try {
//create authenticated client
JumblrClient client = new JumblrClient(params[0], params[1]);
client.setToken(params[2], params[3]);
//get blog's photo posts with reblog information from provided offset
Blog blog = client.blogInfo(params[4]);
Map<String, String> options = new HashMap<String, String>();
options.put("type", "photo");
options.put("offset", params[5]);
options.put("reblog_info", "true");
List<Post> posts = blog.posts(options);
//determine if there is further posts to request (request should returns less than 20 posts if end is reached)
hasMorePosts = (posts.size() == 20);
for (Post post : posts) {
if (post.getType().equals("photo")) {
//cast to PhotoPost for access to specific attributes
PhotoPost photoPost = (PhotoPost) post;
//handle each photos of a single post (required for displaying all photo of a set)
for (Photo photo : photoPost.getPhotos()) {
UnitPhotoPost unitPhotoPost = new UnitPhotoPost();
unitPhotoPost.setId(photoPost.getId());
unitPhotoPost.note_count = photoPost.getNoteCount();
unitPhotoPost.setBlogName(photoPost.getBlogName());
unitPhotoPost.reblog_key = photoPost.getReblogKey();
unitPhotoPost.liked = photoPost.isLiked();
unitPhotoPost.setCaption(photoPost.getCaption());
unitPhotoPost.timestamp = photoPost.getTimestamp();
unitPhotoPost.reblogged_from_name = photoPost.getRebloggedFromName();
unitPhotoPost.photo = photo;
//add unit photo to the list
photoPosts.add(unitPhotoPost);
}
}
}
} catch (Exception e) {
exception = e;
}
//Log access
BlogHistory BlogHistory = new BlogHistory(this.activity, account);
BlogHistory.addEntry(params[4], 1 + Integer.parseInt(params[5]) / 20);
return photoPosts;
}
开发者ID:nioc,项目名称:tumblr-photo-browse,代码行数:49,代码来源:GetTumblrBlogPosts.java
示例8: JumblrTumblrApi
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
public JumblrTumblrApi(JumblrClient client) {
this.client = client;
}
开发者ID:BranLwyd,项目名称:tumblr-sync,代码行数:4,代码来源:JumblrTumblrApi.java
示例9: RequestBuilder
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
public RequestBuilder(JumblrClient client) {
this.client = client;
}
开发者ID:tumblr,项目名称:jumblr,代码行数:4,代码来源:RequestBuilder.java
示例10: setClient
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
public void setClient(JumblrClient client) {
this.client = client;
}
开发者ID:tumblr,项目名称:jumblr,代码行数:4,代码来源:ResponseWrapper.java
示例11: TumblrRetriever
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
public TumblrRetriever(String consumerKey, String consumerSecret, Integer maxResults, Integer maxRequests, Long maxRunningTime) {
this.maxResults = maxResults;
this.maxRequests = maxRequests;
this.maxRunningTime = maxRunningTime;
client = new JumblrClient(consumerKey,consumerSecret);
}
开发者ID:socialsensor,项目名称:socialmedia-abstractions,代码行数:9,代码来源:TumblrRetriever.java
示例12: setClient
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
/**
* Set the JumblrClient used for relative calls from this resource
* @param client the client to use
*/
public void setClient(JumblrClient client) {
this.client = client;
}
开发者ID:tumblr,项目名称:jumblr,代码行数:8,代码来源:Resource.java
示例13: getClient
import com.tumblr.jumblr.JumblrClient; //导入依赖的package包/类
/**
* Get the client for a particular resource
* @return the client
*/
public JumblrClient getClient() {
return this.client;
}
开发者ID:tumblr,项目名称:jumblr,代码行数:8,代码来源:Resource.java
注:本文中的com.tumblr.jumblr.JumblrClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论