Hi... want to import contacts from yahoo address book using java. Been able to get wssid and cookie but not able to move further with the following code using java:-
String req ="http://address.yahooapis.com/api/ws/v1/searchContacts?"+
"format=xml&fields=name,email&appid="+appId+"&WSSID="+wssid;
Cookie cookie=new Cookie("Cookie",new String(Base64.encodeBase64(ycookie.getBytes())));
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(req);
response.addCookie(cookie);
// Send GET request
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: " + method.getStatusLine());
out.println("method.getStatusLine()-> "+method.getStatusLine());
}
InputStream rstream = null;
// Get the response body
try {
rstream = method.getResponseBodyAsStream();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
out.println("e "+e);
}
// Process the response from Yahoo! Web Services
BufferedReader br = new BufferedReader(new InputStreamReader(rstream));
String line;
while((line = br.readLine()) != null){%>
<tr>
<td><%=line%></td>
</tr>
<%}%>
</table>
Executing the above code gives the following error:
method.getStatusLine()-> HTTP/1.1 403 Forbidden
Hope to hear soon from your side.......


