2013-05-04 4 views
0

저는 android에서 새내기입니다. 나는 응용 프로그램이 성공적으로 에 로그인하고 정보를 공유하는 데 동의에 클릭하여 실행하면 내 application.But에 야후 연락처 를 검색하는 응용 프로그램을 구현하고있어하지만 난 오류 -Android에서 야후 연락처를 검색하는 방법은 무엇입니까?

Authentication error: Unable to respond to any of these challenges: 
{oauth=WWW-Authenticate: Oath oath_problem="signature_invalid", realm="yahooapis.com"} 

의 이러한 유형을 직면
error while fetching user contact 

아무도 도와 줄 수 있습니까? 사전에


private void getAllContacts() throws UnsupportedEncodingException,ClientProtocolException, IOException 
    { 
     HttpClient httpclient = new DefaultHttpClient(); 

     String host_url = "http://social.yahooapis.com/v1/user/" + mUSER_GUID+ "/contacts"; 

     String nonce = ""+System.currentTimeMillis(); 
     String timeStamp = ""+(System.currentTimeMillis()/1000L); 

     try{ 
      String params = 
        ""+encode("oauth_consumer_key")+"=" + encode(CONSUMER_KEY) 
        + "&"+encode("oauth_nonce")+"="+encode(nonce) 
        + "&"+encode("oauth_signature_method")+"="+encode("HMAC-SHA1") 
        + "&"+encode("oauth_timestamp")+"="+encode(timeStamp) 
        + "&"+encode("oauth_token")+"="+ACCESS_TOKEN 
        + "&"+encode("oauth_version")+"="+encode("1.0") 

        ; 
      String baseString = encode("GET")+"&"+encode(host_url)+"&"+encode(params); 
      String signingKey = encode(CONSUMER_SECRET)+"&"+encode(ACCESS_TOKEN_SECRET); 
      Log.e(TAG, "base string: " + baseString); 
      String lSignature = computeHmac(baseString, signingKey); 
      Log.e(TAG, "signature: " + lSignature); 
      lSignature = encode(lSignature); 
      Log.e(TAG, "signature enacoded: " + lSignature); 

      String lRequestUrl = host_url 
           + "?oauth_consumer_key="+CONSUMER_KEY 
           + "&oauth_nonce="+nonce 
           + "&oauth_signature_method=HMAC-SHA1" 
           + "&oauth_timestamp="+timeStamp 
           + "&oauth_token="+ACCESS_TOKEN 
           + "&oauth_version=1.0" 
           + "&oauth_signature="+lSignature 
           ; 
      Log.e(TAG, lRequestUrl); 



      HttpGet httpget = new HttpGet(lRequestUrl); 
      ResponseHandler<String> responseHandler = new BasicResponseHandler(); 
      responseBody = httpclient.execute(httpget, responseHandler); 
      Log.e(TAG, "contacts response: " + responseBody); 


      String strUrl=responseBody; 
      DefaultHttpClient httpClient=new DefaultHttpClient(); 
      HttpPost httppost=new HttpPost(strUrl); 
      HttpResponse httpresponse=httpClient.execute(httppost); 
      HttpEntity httpEntity=httpresponse.getEntity(); 

      String strXml=EntityUtils.toString(httpEntity); 

      ArrayList<HashMap<String , String>> arrayList=new ArrayList<HashMap<String,String>>(); 

      XMLParser xmlparser=new XMLParser(); 
      String strxml = xmlparser.getXmlFromUrl(responseBody); 
      Log.e("",""+strxml); // getting xml url here 
      Document doc = xmlparser.getDomElement(strxml);  // getting data object model 
      NodeList nl = doc.getElementsByTagName(KEY_FIELD); // Looping through all item nodes <field> 

      for(int i=0 ; i<nl.getLength() ; i++) 
      { 
       //creating new hash map 
       HashMap<String ,String > map = new HashMap<String, String>(); 
       Element e = (Element) nl.item(i); 

       //Adding each child node to HashMap Key Value pair 
       map.put(KEY_ID  , xmlparser.getValue(e, KEY_ID)); 
       map.put(KEY_TYPE , xmlparser.getValue(e, KEY_TYPE)); 
       map.put(KAE_VALUE , xmlparser.getValue(e, KAE_VALUE)); 

       Log.e("Hash Map","Key Value"+map); 

       //Adding hashlist to arrayList 
       arrayList.add(map); 
       Log.e("ArrayList ","of Contact "+arrayList); 
      } 



     } 

     catch(Exception e) 
     { 
      e.printStackTrace(); 
      Log.e(TAG, "error while fetching user contacts"); 
     } 


    } 

감사 : 여기 내 코드입니다.

답변

0

K-9 mail을 참조하십시오. K-9는 오픈 소스입니다.

+0

서명 오류가 잘못되었습니다. 귀하의 K-9 메일 예에서 어떤 해결책도 찾지 못했습니다. – TJM

관련 문제