You are viewing a single comment's thread from:

RE: Notice of upcoming changes to anyx.io API

in #steem5 years ago

Can you check uft-8 support on your API server?

from beem import Steem
stm  = Steem("https://anyx.io")
from beem.block import Block
b = Block(35097419, steem_instance=stm)
print(b.operations[-22]["value"]["title"])

returns:
<스파ì�´ë�”맨 : 파 프롬 홈> ë¸”ë£¨ì—”ì ¤ 니어 프롬 (퓨처) 홈 💙
whereas

from beem import Steem
stm  = Steem("https://api.steemit.com")
from beem.block import Block
b = Block(35097419, steem_instance=stm)
print(b.operations[-22]["value"]["title"])

returns
<스파이더맨 : 파 프롬 홈> 블루엔젤 니어 프롬 (퓨처) 홈 💙

Sort:  

You've done something wrong in beem; likely you've assumed data in steem operations is always uft-8. It is not guaranteed to be so.
I believe Jussi re-formats steem data to be uft-8. This is not a good thing, it means they alter the inline data, and by doing so, the signature of the transaction will no longer match.

My implementation returns the exact result as you would get if you ran it against a steemd node directly.

A good json parser, like jq, understands things fine. Your example in jq would be:

curl -sd '{"jsonrpc":"2.0", "method":"block_api.get_block", "params":{"block_num":35097419}, "id":"0"}' https://anyx.io | jq '.result.block.transactions[1].operations[0].value.title'

As you can see with this, the result is parsed correctly.

I suggest you try running beem against a steemd node directly to better debug your issue. As an example; the md5sum of the block you have is as reported as follows:

direct to steemd:
curl -sd '{"jsonrpc":"2.0", "method":"block_api.get_block", "params":{"block_num":35097419}, "id":"0"}' localhost:8090 | md5sum
3708e49c94c77626f74ab4958920dc9c  -

anyx.io:
curl -sd '{"jsonrpc":"2.0", "method":"block_api.get_block", "params":{"block_num":35097419}, "id":"0"}' anyx.io | md5sum
3708e49c94c77626f74ab4958920dc9c  -

api.steemit.com:
curl -sd '{"jsonrpc":"2.0", "method":"block_api.get_block", "params":{"block_num":35097419}, "id":"0"}' https://api.steemit.com | md5sum
34bc46f946b44bc4863d3d6434b6c945  -

Thanks a lot, this will definitely help me fixing this issue on beem.

Posted using Partiko Android

A precise and exhaustive answer!
I learned from it too. Thank you.