twitter의 open api 를 사용할 때, oauth support 방식으로 하고자 하는데,
java 기반의 twitter4j 라는 것이 있길래 사용해 보려고 했더니 아래와 같은 문제가 발생합니다.
문제 원인 및 조치방법에 대하여 아시는 분께서는 공유 부탁드립니다.
( twitter4j 대신 signpost 를 사용해도 비슷한 문제가 발생합니다.
java project 로 예제 파일을 만들어 실행시켰을때는 정상적으로 동작하는 것으로 보아
android 코드의 어떤 설정 문제일 것도 같습니다. )
1. 소스코드
(1) activity 의 코드 일부
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
RequestToken requestToken = twitter.getOAuthRequestToken();
(2) manifest.xml 의 일부
<uses-permission android:name="android.permission.INTERNET" /> 추가
(3) lib 폴더에 jar파일 추가 및 build path
twitter4j-core-2.1.0.jar
2. 에러 메시지
Host is unresolved: twitter.com:443
Setting up Redirections through the Emulator Console
Each emulator instance provides a control console the you can connect to, to issue commands that are specific to that instance. You can use the redir
console command to set up redirections as needed for an emulator instance.
First, determine the console port number for the target emulator instance. For example, the console port number for the first emulator instance launched is 5554. Next, connect to the console of the target emulator instance, specifying its console port number, as follows:
telnet localhost 5554
Once connected, use the redir
command to work with redirections. To add a redirection, use:.
add <protocol>:<host-port>:<guest-port>
where <protocol>
is either tcp
or udp
, and <host-port>
and <guest-port>
sets the mapping between your own machine and the emulated system, respectively.
For example, the following command sets up a redirection that will handle all incoming TCP connections to your host (development) machine on 127.0.0.1:5000 and will pass them through to the emulated system's 10.0.2.15:6000.:
redir add tcp:5000:6000