1

我正在尝试使用 jsoup 登录到 Fiverr 并拉入 android 应用程序的订单。这是我的代码。我收到了来自 Fiverr 的 403 禁止。假设我错过了一些东西。有任何想法吗。

  Connection.Response res;
    try {
        res = Jsoup.connect("http://fiverr.com/login")
                .header("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2")
                .userAgent("Mozilla")  
                .data("user_session[username]", "myusername")
                .data("user_session[password]", "mypassword")
                .data("user_session[remember_me]", "1") 
                .method(Method.POST)
                .execute();

        Document doc = res.parse();
        String __utma = res.cookie("__utma");
        String __utmb = res.cookie("__utmb");
        String __utmc = res.cookie("__utmc");
        String __utmz = res.cookie("__utmz");
        String _fiverr_sessions = res.cookie("_fiverr_sessions");
        String _jsuid = res.cookie("_jsuid");
        String fiverr_auth_info = res.cookie("fiverr_auth_info");
        String km_ai = res.cookie("km_ai");
        String km_lv = res.cookie("km_lv");
        String km_ni = res.cookie("km_ni");
        String km_uq = res.cookie("km_uq");
        String km_vs = res.cookie("km_vs");
        String kvcd = res.cookie("kvcd");





        Document doc2 = Jsoup.connect("http://fiverr.com/users/myusername/manage_orders/type/priority")
                .header("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2")
                .userAgent("Mozilla")  
                .cookie("__utma", __utma)
                .cookie("__utmb", __utmb)
                .cookie("__utmc", __utmc)
                .cookie("__utmz", __utmz)
                .cookie("_fiverr_sessions", _fiverr_sessions)
                .cookie("_jsuid", _jsuid)
                .cookie("fiverr_auth_info", fiverr_auth_info)
                .cookie("km_ai", km_ai)
                .cookie("km_lv", km_lv)
                .cookie("km_ni", km_ni)
                .cookie("km_uq", km_uq)
                .cookie("km_vs", km_vs)
                .cookie("kvcd", kvcd)
                .get();

        TextView TextLocation = (TextView)findViewById(R.id.textView1);
        TextLocation.setVisibility(View.VISIBLE);
        TextLocation.setText((CharSequence) doc2.html());
        System.out.println(doc2.html());


    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

这是错误:

  04-18 20:25:54.444: W/System.err(552): java.io.IOException: 403 error loading URL http://fiverr.com/login
  04-18 20:25:54.464: W/System.err(552):    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:414)
  04-18 20:25:54.475: W/System.err(552):    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:391)
  04-18 20:25:54.535: W/System.err(552):    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:157)
  04-18 20:25:54.565: W/System.err(552):    at com.newrock.my5._MainActivity.onCreate(_MainActivity.java:35)
  04-18 20:25:54.575: W/System.err(552):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  04-18 20:25:54.595: W/System.err(552):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  04-18 20:25:54.595: W/System.err(552):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  04-18 20:25:54.635: W/System.err(552):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  04-18 20:25:54.684: W/System.err(552):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  04-18 20:25:54.684: W/System.err(552):    at android.os.Handler.dispatchMessage(Handler.java:99)
  04-18 20:25:54.715: W/System.err(552):    at android.os.Looper.loop(Looper.java:130)
  04-18 20:25:54.755: W/System.err(552):    at android.app.ActivityThread.main(ActivityThread.java:3683)
  04-18 20:25:54.755: W/System.err(552):    at java.lang.reflect.Method.invokeNative(Native Method)
  04-18 20:25:54.764: W/System.err(552):    at java.lang.reflect.Method.invoke(Method.java:507)
  04-18 20:25:54.794: W/System.err(552):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  04-18 20:25:54.824: W/System.err(552):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  04-18 20:25:54.844: W/System.err(552):    at dalvik.system.NativeStart.main(Native Method)
  04-18 20:25:55.364: I/ActivityManager(68): Displayed com.newrock.my5/._MainActivity: +6s716ms
  04-18 20:26:05.184: D/dalvikvm(142): GC_EXPLICIT freed 53K, 47% free 3123K/5831K, external 2183K/2603K, paused 86ms
  04-18 20:26:10.315: D/dalvikvm(243): GC_EXPLICIT freed 6K, 51% free 2725K/5511K, external 716K/1038K, paused 148ms
  04-18 20:26:15.285: D/dalvikvm(282): GC_EXPLICIT freed 8K, 44% free 3366K/5959K, external 716K/1038K, paused 101ms
  04-18 20:26:20.345: D/dalvikvm(311): GC_EXPLICIT freed 10K, 52% free 2776K/5703K, external 716K/1038K, paused 126ms
  04-18 20:26:25.444: D/dalvikvm(345): GC_EXPLICIT freed 7K, 44% free 3533K/6279K, external 716K/1038K, paused 134ms
  04-18 20:26:30.434: D/dalvikvm(356): GC_EXPLICIT freed 3K, 51% free 2718K/5511K, external 716K/1038K, paused 81ms
  04-18 20:29:37.864: D/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol
  04-18 20:29:46.895: D/dalvikvm(122): GC_CONCURRENT freed 439K, 49% free 3096K/6023K, external 716K/1038K, paused 10ms+5ms
  04-18 20:34:37.887: D/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol
  04-18 20:37:42.078: I/dalvikvm(128): Jit: resizing JitTable from 512 to 1024
  04-18 20:39:37.905: D/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol
  04-18 20:44:37.921: D/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol
4

2 回答 2

1

403 错误表明您没有访问指定 URL 所需的权限。

您确定您正在正确处理身份验证吗?

于 2012-04-18T21:07:56.797 回答
0

这是一个身份验证问题。确保在尝试对帐户执行任何操作时实现特定于 Fiverr API 的所有身份验证。即使 oAuth 有问题,您也可能会收到此代码 403...

于 2012-06-09T20:32:49.447 回答