本文介绍了创建PicasawebService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从公开的Picasa相册中获取标题和URL.但是,我一开始就陷入了困境:我无法创建新的PicasawebService.

I try to get the titles and URLs from a public Picasa album. But I am stuck at the very beginning: I cannot create a new PicasawebService.

我的代码:

import java.util.List;
import java.io.File;
import java.net.URL;

import com.google.gdata.client.*;
import com.google.gdata.client.photos.*;
import com.google.gdata.data.*;
import com.google.gdata.data.media.*;
import com.google.gdata.data.photos.*;
import java.util.ArrayList;

public class PicasaManager implements PicasaConnector {

    public List<Avatar> getPhotoURLs() throws Exception {
        PicasawebService myService = new PicasawebService("HI");

        myService.setUserCredentials("[email protected]", "mypassword");

        ArrayList<Avatar> rl = new ArrayList<Avatar>();

        URL feedUrl = new URL("https://picasaweb.google.com/111420671758947023853/EWA2012");
        System.out.println("dddddddddddddddddd");
        AlbumFeed feed = myService.getFeed(feedUrl, AlbumFeed.class);

        for (PhotoEntry photo : feed.getPhotoEntries()) {
            Avatar a1 = new Avatar();
            a1.setDescription(photo.getTitle().getPlainText());
            a1.setUrl(photo.getMediaThumbnails().get(0).getUrl());
            rl.add(a1);
        }

        return (rl);
    }
}

错误消息:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;
    at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableTypes(AltFormat.java:399)
    at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableXmlTypes(AltFormat.java:387)
    at com.google.gdata.wireformats.AltFormat.<clinit>(AltFormat.java:49)
    at com.google.gdata.client.Service.<clinit>(Service.java:558)
    at tuwien.big.mensch.utilities.PicasaManager.getPhotoURLs(PicasaManager.java:27)
    at tuwien.big.mensch.utilities.test.main(test.java:29)

  • test.java是我的带有公共static void main方法的测试类,
  • 头像是一个具有两个变量的类:description和url,两者都有getter和setter.
  • PicasaManager.java文件的netbeans IDE第27行中是:PicasawebService myService = new PicasawebService("HI");
  • 实现的接口仅定义getPhotoURLs()方法
    • test.java is my test class with the public static void main method,
    • Avatar is a class with two variables: description and url, there are getters and setters for both
    • in my netbeans IDE line 27 of the PicasaManager.java file is: PicasawebService myService = new PicasawebService("HI");
    • the implemented interace only defines the getPhotoURLs() method
    • 我不知道如何解决这个问题,我希望这里的人能帮助我.

      I have no idea how to solve this problem, i hope somebody here can help me.

      推荐答案

      您是否包含gdata-core-1.0.jar和guava-12.0.jar?祝Web工程UE4的其余部分一切顺利;-)

      Have you included gdata-core-1.0.jar and guava-12.0.jar? Good luck on the rest of Web Engineering UE4 ;-)

      这篇关于创建PicasawebService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 06:31