samczsun / Skype4J

Skype API written in Java. Does not support P2P chats
Apache License 2.0
145 stars 48 forks source link

ConnectionException:{"errorCode":201,"message":"To field is invalid"} #99

Open Doran1990 opened 8 years ago

Doran1990 commented 8 years ago

I can't send message to some firends, but I can send message with skype or web skype. the error is : pls help me how to slove it. com.samczsun.skype4j.exceptions.ConnectionException: Cause: While sending message Response: 400 Bad Request Begin Message

{"errorCode":201,"message":"To field is invalid"}

    End message

at com.samczsun.skype4j.internal.ExceptionHandler.generateException(ExceptionHandler.java:101)
at com.samczsun.skype4j.internal.Endpoints$EndpointConnection.connect(Endpoints.java:377)
at com.samczsun.skype4j.internal.Endpoints$EndpointConnection.connect(Endpoints.java:307)
at com.samczsun.skype4j.internal.Endpoints$EndpointConnection.post(Endpoints.java:291)
at com.samczsun.skype4j.internal.chat.ChatImpl.sendMessage(ChatImpl.java:85)
ducc commented 8 years ago

Code please :)

Doran1990 commented 8 years ago

This is my code: I get all contacts ,and send private message Collection contacts = skype.getAllContacts(); Object[] ary = contacts.toArray(); for(int i =0;i<ary.length;i++){

Contact contact = (Contact)ary[i]; Chat chat = contact.getPrivateConversation(); ChatMessage chatMessage = null; chatMessage = chat.sendMessage(Message.create().with(Text.plain(msg)).with(Text.rich(link).withLink(link))); }

Doran1990 commented 8 years ago

I send message to all of contacts,sometime get the error: ConnectionException: Cause: While sending message Response: 504 Gateway Timeout Begin Message

{"errorCode":507,"message":"Failure due to: AclNotAvailable."}

    End message

at com.samczsun.skype4j.internal.ExceptionHandler.generateException(ExceptionHandler.java:101) at com.samczsun.skype4j.internal.Endpoints$EndpointConnection.connect(Endpoints.java:377) at com.samczsun.skype4j.internal.Endpoints$EndpointConnection.connect(Endpoints.java:307) at com.samczsun.skype4j.internal.Endpoints$EndpointConnection.post(Endpoints.java:291) at com.samczsun.skype4j.internal.chat.ChatImpl.sendMessage(ChatImpl.java:85)

ducc commented 8 years ago

Whilst we are waiting for @samczsun, why not use a for loop for iterating contacts?

for (Contact contact : skype.getAllContacts()) {
  // do what you want for each contact here
}
Doran1990 commented 8 years ago

@Sponges sure, can use iterating.

Doran1990 commented 8 years ago

any body help me?

Doran1990 commented 8 years ago

it seem the error occur when send message to msn friend

samczsun commented 8 years ago

Could you elaborate on what you mean by "msn friend"?