Респектабельные Гуру, я хочу загрузить фотографии на flickr, но перед загрузкой не могу получить запрос от flickr и получить ошибку.
Мой код выглядит следующим образом:
public class AuthinticationActivity {
public static void auth() throws
IOException, FlickrException {
Flickr flickr = new Flickr("MyApiKey",
"SecretKey", new
REST(Flickr.DEFAULT_HOST));
Flickr.debugStream = true;
AuthInterface authInterface =
flickr.getAuthInterface();
Scanner scanner = new
Scanner(System.in);
Token token = authInterface.getRequestToken();
System.out.println("Gtoken: " + token);
String url = authInterface.getAuthorizationUrl(token, Permission.WRITE);
System.out.println("Follow this URL to authorise yourself on Flickr");
System.out.println(url);
System.out.println("Paste in the token it gives you:");
System.out.print(">>");
String tokenKey = scanner.nextLine();
scanner.close();
Token requestToken = authInterface.getAccessToken(token, new Verifier(tokenKey));
System.out.println("Authentication success");
Auth auth = authInterface.checkToken(requestToken);
// This token can be used until the user revokes it.
System.out.println("Token: " + requestToken.getToken());
System.out.println("Secret: " + requestToken.getSecret());
System.out.println("nsid: " + auth.getUser().getId());
System.out.println("Realname: " + auth.getUser().getRealName());
System.out.println("Username: " + auth.getUser().getUsername());
System.out.println("Permission: " + auth.getPermission().getType());
}
public static void main(String[] args) {
try {
AuthinticationActivity .auth();
System.out.println();
} catch (Exception e) {
e.printStackTrace();
}
System.exit(0);
}}
И ошибкаЯ вхожу, как показано ниже:
W/System.err: org.scribe.exceptions.OAuthConnectionException: There was a problem while creating a connection to the remote service.
at org.scribe.model.Request.send(Request.java:70)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:59)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:40)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:45)
at com.mobilepricess.imagetry.Tryna.main(AuthinticationActivity .java:26)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
at java.net.InetAddress.lookupHostByName(InetAddress.java:431)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:220)
at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:176)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:108)
at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:482)
at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:465)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:447)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:353)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:468)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:118)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:249)
at org.scribe.model.Request.addBody(Request.java:136)
at org.scribe.model.Request.doSend(Request.java:114)
at org.scribe.model.Request.send(Request.java:66)
... 18 more
Пожалуйста, помогите мне, я потратил дни на поиски в Интернете и поиск, но все же, нет удачи, Мое подключение к Интернету в порядке, и нет брандмауэра или какой-либо другойописываемая безопасность в сети для блокировки запроса.