PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, December 28, 2021

[FIXED] Format balance availablefrom facebook api

 December 28, 2021     facebook, facebook-graph-api, facebook-javascript-sdk, facebook-marketing-api, facebook-php-sdk     No comments   

Issue

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.

enter image description here

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.

enter image description here


Solution

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.



Answered By - Matteo
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing