Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
应用程序引擎上的Facebook积分示例?_Facebook_Google App Engine_Facebook Credits_Credits - Fatal编程技术网

应用程序引擎上的Facebook积分示例?

应用程序引擎上的Facebook积分示例?,facebook,google-app-engine,facebook-credits,credits,Facebook,Google App Engine,Facebook Credits,Credits,有没有在谷歌应用程序引擎上使用facebook积分的例子 我找到了这篇博文,但它不完整 我和朋友们一起在应用程序引擎上运行了这个示例,试图用积分来扩展它,但到目前为止运气不佳 还搜索了FB开发者论坛,一无所获 你能给我指点什么资源吗 什么不起作用: 1) 当我点击“用Facebook支付”按钮时,我得到一个“应用程序错误”,没有任何错误代码。 -检查javascript控制台 -已检查fb应用程序设置 -已在本地服务器和生产服务器上尝试 2) callback.py未完成,因为我无法解析已签名

有没有在谷歌应用程序引擎上使用facebook积分的例子

我找到了这篇博文,但它不完整

我和朋友们一起在应用程序引擎上运行了这个示例,试图用积分来扩展它,但到目前为止运气不佳

还搜索了FB开发者论坛,一无所获

你能给我指点什么资源吗

什么不起作用:
1) 当我点击“用Facebook支付”按钮时,我得到一个“应用程序错误”,没有任何错误代码。
-检查javascript控制台
-已检查fb应用程序设置
-已在本地服务器和生产服务器上尝试

2) callback.py未完成,因为我无法解析已签名的请求(py中没有可供我学习的代码)

3) 我基本上是将Suinova Design(上面的链接)的代码添加到现有的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;

您的python代码看起来相当正常,所以我猜您只是在授权方面遇到了问题。根据您的授权方式(一个比信用证系统更复杂的流程),您可能会收到一个只有部分授权的签名请求。。。这意味着您仅被授权访问facebook的某些部分,但通常无权访问活动/登录用户(即我)


您可以通过确定您的签名请求是否为完整的80多个字符(而不是大约40个字符)来验证这一点。通常,我尝试通过解密配置文件(签名的请求)进行身份验证,如果失败,那么我尝试使用以前存储的cookie,如果失败,那么我尝试重新登录用户。我通过在调用周围放置try/except来确定失败,以便通过GraphAPI获取“me”对象。

您的python代码看起来相当正常,因此我猜您只是在授权方面遇到了问题。根据您的授权方式(一个比信用证系统更复杂的流程),您可能会收到一个只有部分授权的签名请求。。。这意味着您仅被授权访问facebook的某些部分,但通常无权访问活动/登录用户(即我)


您可以通过确定您的签名请求是否为完整的80多个字符(而不是大约40个字符)来验证这一点。通常,我尝试通过解密配置文件(签名的请求)进行身份验证,如果失败,那么我尝试使用以前存储的cookie,如果失败,那么我尝试重新登录用户。我通过在调用周围放置try/except来确定失败,以便通过GraphAPI获取一个“我”对象。

我决定资助一个小型开源项目,在App Engine上实现积分。有一种感觉,人们会需要这个。链接在这里:你能扩展一下“不走运”吗?具体来说,你有什么问题?只是编辑了文章以显示更多的模式。希望有人能提出建议!我决定资助一个小型开源项目,在AppEngine上实现学分。有一种感觉,人们会需要这个。链接在这里:你能扩展一下“不走运”吗?具体来说,你有什么问题?只是编辑了文章以显示更多的模式。希望有人能提出建议!
//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))