在Google App Engine上是否有使用Facebook積分的例子?Facebook App Credits在App Engine上的示例?
我發現這個博客帖子,但它不是完整的 http://blog.suinova.com/2011/01/integrating-facebook-credits-api-into.html
我拿到樣品runwithfriends example在使用App Engine,試圖與積分展開,至今沒有運氣。
也搜索了FB開發者論壇,一無所獲。
您可以指向我的任何資源?
什麼不工作:
1)當我點擊「與Facebook交易」按鈕,我得到一個「應用程序錯誤」,沒有任何錯誤代碼。
-Checked JavaScript控制檯
-Checked本地服務器和生產服務器
2)callback.py是不完整的在FB應用程序設置
-Tried,因爲我無法解析簽名的請求(無代碼在py中可供我學習)
3)我基本上做的是從Suinova Designs(上面的鏈接)添加代碼到現有的Run With Friends應用代碼。沒有按預期結果。
到目前爲止我的代碼:
//payment_page.html
<html>
<table>
<tr><th>Name</th><th>Price</th><th> </th></tr>
<tr><td>Something to buy</td><td>10 FC</td><td><a href="" onclick="return buyit();">
<img src="http://www.facebook.com/connect/button.php?app_id=215638625132268&feature=payments&type=light_l" />
</a></td></tr>
</table>
// javascript
function buyit(){
FB.ui({
method:'pay',
purchase_type:'item',
order_info:{
item_id:'myitem',
title:'Something to buy',
price:2,
description:'Whatever',
image_url:'http://www.facebook.com/images/gifts/21.png',
product_url:'http://www.facebook.com/images/gifts/21.png'}
},
function(resp){
if(resp.order_id) window.top.location='http://apps.facebook.com/runwithfriends trial'; else alert(resp.error_message);
});
return false;
}
//callback.py
class FacebookPaymentRequest(webapp.RequestHandler):
def post(self):
signed_request = parse_signed_request(self.request.get('signed_request'),conf.FACEBOOK_APP_SECRET)
payload = signed_request['credits'] #credits:{buyer:int,order_id:int,order_info:{},receiver:int}
order_id = payload['order_id']
method = web.request.get('method')
return_data = {'method':method}
if method == 'payments_get_items':
order_info = payload['order_info'] #order_info:{item_id:'',title:'',description:'',price:0,image_url:'',product_url:''}
item = simplejson.loads(order_info) #needs to convert JSON string to dict
#check item,price,etc and reply
return_data['content'] = [item]
elif method == 'payments_status_update':
status = payload['status']
return_data['content'] = {'status':'settled','order_id':order_id}
if status == 'placed':
#just return settled status to Facebook, this may be called twice
order_details = simplejson.loads(payload['order_details'])
#check and log here
elif status == 'settled':
order_details = simplejson.loads(payload['order_details'])
#order_details:{order_id:0,buyer:0,app:0,receiver:0,amount:0,update_time:0,time_placed:0,data:'',items:[{}],status:'placed'}
buyer = order_details['buyer']
item = order_details['items'][0]
#now save this transaction into our database
else:
#may be refunded, canceled, log the activity here
return_data['content']['status'] = status
self.response.out.write(simplejson.dumps(return_data))
我決定資助一個小型的開源計劃,在App Engine上實施信用。有一種感覺,人們會需要這個。鏈接在這裏:http://forum.developers.facebook.net/viewtopic.php?pid=340374#p340374 – ben 2011-05-04 07:54:49
你可以擴大「沒有運氣」?你有什麼問題? – 2011-05-04 16:46:34
剛剛編輯帖子以顯示更多模式。希望有人能建議! – ben 2011-05-06 00:03:56