2013-03-16 3 views
2

이 내 코드입니다은 { "오류": { "메시지": "(# 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에 이미지가있는 메시지를 게시하고 싶습니다. json json이 맞습니다. json formatter editor에서 확인했습니다. 다음 예외가 있습니다. 해결 방법을 제안해야합니다.

는 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 양식을 게시 할 수 없습니다. 누구든지이 문제를 해결하십시오. json으로 이미지와 마술을 묶는 첨부 파일을 보내려고합니다.

+0

이 – Dinesh

답변

1

.

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; 
      } 

     } 
2

당신은 또한이 매개 변수를 넣어 시도 할 수 있습니다 :

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

에만 메시지를 이미지로하지 메시지가 게시 UR 로그 캣 예외를 게시 예외 사이로. –

+0

답변을 수정했습니다. 시도해보고 도움이되는지 알려주세요! –

+0

귀하의 답변에 따라 내 질문을 업데이트했습니다. 도움에 감사드립니다. + 1 귀하의 도움에 대 한 업데이트를 참조하십시오 및 그것을 대답합니다. –

관련 문제