Earn Facebook Credits:Integrating the Offer Shortcut

文章介绍了如何在游戏中通过点击触点提供Facebook Credits给玩家,并引导他们完成广告商的优惠来获得虚拟货币奖励。通过使用特定的JavaScript代码片段,开发者可以轻松集成此功能,并监听广告商优惠的完成情况,以及调整代码以适应HTTPS加载需求。

The Facebook Offer Shortcut allows you to offer your game players Facebook Credits in exchange for completing advertiser offers.

The Offer's Shortcut in-game touchpoint

Fig. 1 — An in-game touchpoint promoting Credits.

The Offers Shortcut

Fig. 2 — A player has clicked the in-game touchpoint, displaying the Offer Shortcut.

Code Snippet

 

< script  type ="text/javascript"  src ="http://assets.tp-cdn.com/static3/js/api/payment_overlay.js" ></ script >
< script  type ="text/javascript" >
  
function  earnCredits() {
    TRIALPAY.fb.show_overlay(
' <app_id> ' ' fbpayments ' , {sid: ' <sid> ' });
  }
</ script >

To display the Offer Shortcut, call the earnCredits() function whenever a customer clicks the in-game touchpoint. Note that you must replace the placeholders below with values.

Placeholders

  • <app_id> — Replace this with your Facebook application ID.
  • <sid> — Pass us the customer’s third-party ID through this placeholder.

Listening for Events

Offer Completions

You can determine when a customer completes an advertiser’s offer by adding the following code (in green) to the code snippet:

 

< script  type ="text/javascript"  src ="http://assets.tp-cdn.com/static3/js/api/payment_overlay.js" ></ script >
< script  type ="text/javascript" >
 
function  my_ontransact(obj) { alert( ' my_ontransact. completions:  '   +  obj.completions  +   " . vc_amount:  "   +  obj.vc_amount); }

  
function  earnCredits() {
    TRIALPAY.fb.show_overlay(
' <app_id> ' ' fbpayments ' , {sid: ' <sid> ' , onTransact: ' my_ontransact ' });
  }
</ script >

When a customer completes an offer, we’ll call the my_ontransact object and you can retrieve the number of completions (completions) and virtual currency reward amount (vc_amount) properties.

Note that if we timeout while waiting for a completion notification from the advertiser, we’ll call the function anyway and set both completion and vc_amount to zero.

Offer Overlay Opening/Closing

You can call your own function whenever a customer opens or closes the offer overlay by defining onOpen or onClose parameters in the code snippet.

For example:

 

< script  type ="text/javascript"  src ="http://assets.tp-cdn.com/static3/js/api/payment_overlay.js" ></ script >
< script  type ="text/javascript" >
  
function  earnCredits() {
    TRIALPAY.fb.show_overlay(
' <app_id> ' ' fbpayments ' , {sid: ' <sid> ' , onClose: ' overlay_closed ' });
  }
</ script >

In the example above, whenever a customer closes the offer overlay, the Offer Shortcut will call a function named overlay_closed, which you have defined elsewhere in the frame/page.

HTTPS

If your game or app will be loaded over HTTPS, you must load the Offer Shortcut over HTTPS as well. To do this, update the code snippet’s src URL (in green) to point to our secure server:

 

< script  type ="text/javascript"  src ="https://s-assets.tp-cdn.com/static3/js/api/payment_overlay.js" ></ script >
< script  type ="text/javascript" >
  
function  earnCredits() {
    TRIALPAY.fb.show_overlay(
' <app_id> ' ' fbpayments ' , {sid: ' <sid> ' });
  }
</ script >

If you revert to HTTP for customers who have disabled Facebook’s secure browsing feature, we strongly recommend that you load the Offer Shortcut over HTTP as well. This will provide a better user experience for your customers.

 

 

 

 

摘自:http://help.trialpay.com/credits/?p=269

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值