Android Pinterest SDK:无法上传

时间:2014-05-15 12:58:50

标签: android pinterest

我尝试使用Android Pin It SDK将PinIt与我的应用集成,但它给了我错误

Pin无法更新并尝试重试

这是我的代码

// pin it
PinItButton.setDebugMode(true);
PinItButton.setPartnerId(CLIENT_ID);

PinItButton pinIt = (PinItButton) findViewById(R.id.pin_bt);
pinIt.setImageResource(R.drawable.icon_pinterest);
pinIt.setImageUrl("http://images.frandroid.com/wp-content/uploads/2012/11/Test-LG-Nexus-4-Gauche.png");
pinIt.setUrl("http://images.frandroid.com/wp-content/uploads/2012/11/Test-LG-Nexus-4-Gauche.png");
pinIt.setDescription(offerData.getOffer_description());     
pinIt.setListener(_listener);

PinItListener _listener = new PinItListener() {

    @Override
    public void onStart() {
        super.onStart();
        Log.i(APP_TAG, "PinItListener.onStart");
        statistics();
    }

    @Override
    public void onComplete(boolean completed) {
        super.onComplete(completed);
        if(completed)
            Log.i(APP_TAG, "PinItListener.onComplete");
        else
            Log.e(APP_TAG, "PinItListener.NotComplete");
    }

    @Override
    public void onException(Exception e) {          
        super.onException(e);
        e.printStackTrace();
        Log.i(APP_TAG, "PinItListener.onException");
    }

};

有谁知道这段代码有什么问题?

1 个答案:

答案 0 :(得分:0)

First declare this in onCreate() of activity:

PinIt pinIt=new PinIt();

after that use this method in your pinit button click and pass imageUrl and description:

public void pinImageOnPinterest(String imageUrl,String description){
        PinIt.setPartnerId(CLIENT_ID);
        pinIt.setImageUrl(imageUrl);
        pinIt.setDescription(description);
        pinIt.setUrl("your set url");
        pinIt.setListener(new PinItListener() {
              @Override
            public void onStart() {
                // TODO Auto-generated method stub
                super.onStart();
            }

               @Override
            public void onComplete(boolean completed) {
                // TODO Auto-generated method stub
                   super.onComplete(completed);
                   if(completed){
                       Log.w("pinit", "Image posted on pinterest");
                       //Toast.makeText(getActivity(), "Image Posted", Toast.LENGTH_SHORT).show();
                   }
            }
               @Override
            public void onException(Exception e) {
                // TODO Auto-generated method stub
                   super.onException(e);
                   Toast.makeText(getActivity(), "Please install Pinterest App", Toast.LENGTH_SHORT).show();
                   Log.w("pinit", "pinit exception :"+e);

            }
        });
        pinIt.doPinIt(getActivity());
    }

希望这会对你有所帮助。