OpenX Java API。如何获得广告商?

时间:2012-11-22 08:32:46

标签: java openx

我在Web服务器上安装了OpenX-2.8.10。

我正在使用它的示例连接到OpenX Server。我想从服务器获取广告商,我有问题。我正在尝试使用AdvertiserService,但没有成功。

代码在这里:

public class Prototype {
    private final static String serverURL = "http://demo.pwi.ru";
    private final static String openadsDir = "/openx";
    private final static String logonService = "/www/api/v1/xmlrpc/LogonXmlRpcService.php";
    private final static String agencyService = "/www/api/v1/xmlrpc/AgencyXmlRpcService.php";
    private final static String username = "admin";
    private final static String password = "875698";
    private static Integer id = 1;

    public static void main(String[] args) {
        final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();

        try {
            config.setServerURL(new URL(serverURL + openadsDir + logonService)); 
            XmlRpcClient client = new XmlRpcClient();
            client.setConfig(config);

            String sessionId = (String) client.execute("logon", new Object[]{username, password});
            System.out.println("User logged on with session Id: " + sessionId);

            AdvertiserService service = new AdvertiserService(client, sessionId);
            service.setSessionId(sessionId);

            System.out.println("AdvertiserService: " + service.getAdvertiser(id ));
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (XmlRpcException e) {
            e.printStackTrace();
        }
    }
}

控制台说:

用户使用会话ID登录:phpads50addd559301e5.24695272 org.apache.xmlrpc.XmlRpcException:无法创建输入流:demo.pwi.ru//phpads50addd559301e5.24695272//AdvertiserXmlRpcService.php     在org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:65)     在org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:141)     在org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)     在org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:44)     在org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:53)     在org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)     在org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:136)     在org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:125)     在org.openads.proxy.AbstractService.execute(AbstractService.java:111)     在org.openads.proxy.AdvertiserService.execute(AdvertiserService.java:1)     在org.openads.proxy.AdvertiserService.getAdvertiser(AdvertiserService.java:118)     在org.openads.proxy.prototype.Prototype.main(Prototype.java:36) 引起:java.io.FileNotFoundException:demo.pwi.ru//phpads50addd559301e5.24695272//AdvertiserXmlRpcService.php     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)     在org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:63)     ......还有11个 引起: java.io.FileNotFoundException:demo.pwi.ru//phpads50addd559301e5.24695272//AdvertiserXmlRpcService.php     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)     在org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:63)     在org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:141)     在org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)     在org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:44)     在org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:53)     在org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)     在org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:136)     在org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:125)     在org.openads.proxy.AbstractService.execute(AbstractService.java:111)     在org.openads.proxy.AdvertiserService.execute(AdvertiserService.java:1)     在org.openads.proxy.AdvertiserService.getAdvertiser(AdvertiserService.java:118)     在org.openads.proxy.prototype.Prototype.main(Prototype.java:36)

0 个答案:

没有答案