{ “错误”:{ “消息”: “(#100)缺少消息或附件”, “类型”: “OAuthException”, “代码”:100}}

问题描述:

这是我的代码{ “错误”:{ “消息”: “(#100)缺少消息或附件”, “类型”: “OAuthException”, “代码”:100}}

private void postToWall(String msg) { 
    Bundle parameters = new Bundle(); 

    JSONObject attachment = new JSONObject(); 

    String myjosn="{\"name\":\"LangGuage\",\"href\":\"http://www.hunkatech.com\",\"caption\":\" \",\"description\":\""+messageToPost+"\",\"media\":[{\"type\":\"image\",\"src\":\"http://hwsdemos.com/LangGuage/medal_1.png\",\"href\":\"http://www.hunkatech.com\"}],\"properties\":{\"Powered by:\":{\"text\":\"Hunka Technology Pvt. Ltd.\",\"href\":\"http://www.hunkatech.com\"}}}"; 

      try { 



     parameters.putString(Facebook.TOKEN, facebook.getAccessToken()); 

      parameters.putString("attachment",myjosn.toString()); 


     String response = facebook.request("me/feed", parameters, "POST"); 

     System.out.println("----responce" + response); 

     if (response.contains("Duplicate status message")) { 
      progressHandler.sendEmptyMessage(1); 
      resp = 1; 

     } else if (response == null || response.equals("") 
       || response.equals("false") || response.contains("error")) { 
      Log.d("error", "error response"); 
     } else { 
      progressHandler.sendEmptyMessage(0); 
      resp = 0; 

     } 

    } catch (Exception e) { 
     Log.e(TAG, "Posting fail"); 

     e.printStackTrace(); 

    } 

} 

我想用Facebook上的图像发布消息wall.my json是正确的我已经在json格式化编辑器上检查过它了。我有如下的exception.need建议如何解决它。

UPDATE:我的消息和图像贴有下面的代码帮助:

parameters.putString("link", "http://www.hunkatech.com"); 
parameters.putString("picture", "http://hwsdemos.com/LangGuage/medal_1.png"); 
parameters.putString("name", "LangGuage");// name of link 
parameters.putString("captions", "hello"); 
parameters.putString("message", "This is my message!!"); 

但我希望能有像左边的文字,但上面的代码给出的结果Imgae下面的消息。 更新:我无法发布任何形式json.can任何人请解决这个问题我想发送附件,绑定图像和massege与json。

+0

发布乌尔logcat的例外 – Dinesh 2013-03-16 06:09:27

在这里,我是怎么做到的。

private void publishFeedDialog() { 
     System.out.println("Working"); 
     Bundle postParams = new Bundle(); 
     postParams.putString("name", "I am an Engineer"); 
     postParams.putString("caption", 
       "Working very heard to make things work."); 
     postParams 
       .putString("description", 
         "This project is killing me, Still I am trying, and finally I got success."); 
     postParams.putString("link", "http://www.kodebusters.com"); 
     postParams 
       .putString(
         "picture", 
         "http://cdn1.iconfinder.com/data/icons/iconslandsport/PNG/128x128/Soccer_Ball.png"); 

     new MYasync(postParams).execute(); 

    } 

运行网络调用的AsyncTask或者它可以通过例外

class MYasync extends AsyncTask<Void, Void, Void> { 

      Bundle params; 
      private String res; 

      public MYasync(Bundle params) { 
       super(); 
       this.params = params; 
      } 

      @Override 
      protected void onPostExecute(Void result) { 
       System.out.println(res); 
       super.onPostExecute(result); 
      } 

      @Override 
      protected Void doInBackground(Void... pp) { 
       try { 
        res = facebook.request("me/feed", params, "POST"); 

       } catch (FileNotFoundException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } catch (MalformedURLException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } catch (IOException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 
       return null; 
      } 

     } 

你可以尝试另外把这个参数:

parameters.putString("message", "this is my message"); 

编辑:

你可以试试:

parameters.putString("link", "http://www.hunkatech.com"); 
parameters.putString("picture", "http://hwsdemos.com/LangGuage/medal_1.png"); 
parameters.putString("name", "LangGuage");// name of link 
parameters.putString("captions", "hello"); 
parameters.putString("message", "This is my message!!"); 
+0

唯一的消息是由与图像不留言张贴。 – 2013-03-16 06:05:03

+0

我编辑了答案。尝试让我知道,如果它有帮助! – 2013-03-16 06:13:23

+0

我已根据您的答案更新了我的问题。感谢您的帮助!!! + 1的帮助,请参阅update并逐一回答。 – 2013-03-16 06:15:16