开发者

Facebook Credits and Foreign currency

开发者 https://www.devze.com 2023-04-04 20:00 出处:网络
I am developing an application that uses FBCredits as a currency, however, my clients are going to be paying in their local currency (ILS, israeli sheqel).

I am developing an application that uses FB Credits as a currency, however, my clients are going to be paying in their local currency (ILS, israeli sheqel).

I know the rate for 1 credit is 10 cents, however, the price in ILS seems to be changing according to changes in the exchange-rates of USD-ILS.

Is there a way to query Facebook Server 开发者_如何学Cto know the prices users are going to be charged in their local money? Like a way to query the pricelist. Many new users don't understand the concept of credits and i'd like to show them what they're about to pay in local money.


The Facebook Credits API doesn't have exchange rate information available. You could request this feature on their developer group. You're best bet would be to pull down an exchange rate feed (there are tons available if you search) and display that with a warning that it is just an estimated rate and that it is dependent on the actual exchange rate Facebook uses.


xe.com is a great feed , you can also pull data from yahoo or google finance


As stated by OffBySome, Facebook do not have exchange rate information available. Thinking about this, I can see why they don't have this as they do not want you to display the local currency price for items. Although at the moment Facebook Credits are relatively new, and there is a lot of confusion for end users, eventually when it becomes widespread there won't be these issues.

I would suggest for now (as that is what I have done - here one Facebook Credit is currently ~7p) that you just hard code in your app the price of 1 Facebook Credit in your local currency, and if required display this. I think one of the reasons why Facebook don't support this is that they didn't envisage apps using Credits to be restricted to one territory, however in reality not everything is a game to be used worldwide. :)


Just to sum this question up, I tried two methods. One was to pull the rate every 10 minutes from openexchange using this python function:

def update_ils_rate():
    print "Updating ILS/USD exchange rate"
    url = 'http://openexchangerates.org/latest.json'
    response = requests.request('get', url)
    content = response.content
    data = loads(content)
    return data['rates']['ILS']

However it seems that facebook credits calculates ILS(israeli sheqel) rate according to a different rate (calculations were off by a little). So we have decided to pull xml data from israel's central bank, using this function:

import requests, BeautifulSoup

def get_ils_rate():
    response = requests.request('get', 'http://www.bankisrael.gov.il/currency.xml')
    content = response.content    
    soup = BeautifulSoup(content)
    currencies = soup.findAll('currency')
    for c in currencies:
        if c.currencycode.contents[0]=='USD':
            return float(c.rate.contents[0])
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号