Java invoke Sina Weibo API int64 type parameter incoming method __java

Source: Internet
Author: User

Sina Weibo data mining recently, need to call the Sina Weibo API, which requires the incoming user ID, that is, UID, for the int64 type.

source_id False Int64 The UID of the source user.

And there is no int64 type in Java, it's natural to start with long, because the range is not enough with Int.

Long uid = 2479449007l; or long uid = 2479449007;

Invokes the UID as a parameter to the API, resulting in an error

{"Error": "Parameter (source_id) ' s value invalid,expect (long), but get (2.479449007E9), and the doc for more info.", "error_cod E ": 10017," request ":"/2/friendships/show.json "}

You can see that Java automatically uses the UID notation in scientific notation.

How to not let it automatically converted into scientific counting method, toss for a long time, has not been able to ruyi.

At last I tried to pass the string directly,

String uid = "2479449007";

It seems that this API document, although it says you want to pass in the int64, can be passed in directly to the string.


BTW

If you read a string as a parameter modulation API in text file (TXT) form, the encoding format is ansi,utf-8 and the following error will be reported.

{"Error": "Parameter" (source_id) ' s value invalid,expect (long), but get (1978506667), and the doc for more info. "," Error_code " : 10017, "request": "/2/friendships/show.json"} Sina Weibo is so proud ....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.