简体   繁体   中英

Format balance availablefrom facebook api

I am trying to get the balance that a facebook ad account has positive or negative, however, I am following the facebook documentation and the same says that the field is "balance", below I am putting the print taken from the facebook documentation.

在此处输入图像描述

I'm getting this value according to the documentation the problem is that I don't know how to format the value correctly, the value is coming without a decimal separator, has anyone been there? How do I know when to format the value with decimal or not?

Below is the printout of my return that I'm getting from the API.

在此处输入图像描述

You should consider the AdAccounts currency offset, as described here , as a static table:

Offset

Each currency has an offset which specifies how Facebook should handle its sub-divisions. This is to ensure that the minimum bid, such as "1", is a usable value for the currency.

Example offset 100

If a currency has an offset of 100 then the minimum allowed bid is assumed to be 1/100 of the currency base unit. For example, if you place a bid of "1" on an ad account based on USD the bid will be 0.01 USD.

Example offset 1

If a currency has an offset of 1 then the minimum allowed bid is assumed to be in the currency base unit. For example, if you place a bid of "1" on a ad account based on JPY the bid will be 1 JPY.

A sample of the table:

Name Code Offset
Algerian Dinar DZD 100
Argentine Peso ARS 100
.. .. ..
Brazilian Real BRL 100
.. .. ..
Chilean Peso CLP 1
.. .. ..

So for your currency you should consider an offset of 100.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM