Sponsorship is one of the most important features of the phpFox platform. Purpose of this tutorial is to provide some guideline for developers who want to integrate this feature with their apps.
Sponsor in app's block
...
# | Name | Description |
---|---|---|
1 | can_sponsor_ | Can members of this user group mark a an |
2 |
| How much is does the sponsor space worth for |
3 | auto_publish_sponsored_ | After the user has purchased a sponsored space, should the |
Note: replace
app
with your app's alias
Sponsor methods
phpFox provides 2 sponsor methods: Sponsor without fee and Purchase sponsor.
...
When can_sponsor_app
is Yes, user users of that user group can sponsor item without paying fee.
All you have to do in your app is mark item as sponsor by database query and don't forget to add sponsor via function addSponsor()
in class Ad_Service_Process
.
...
Code Block | ||||
---|---|---|---|---|
| ||||
{permalink module='ad.sponsor' id={item-id} section={app}}
|
Note: replace
app
with your item app alias anditem-id
with your item id.
If your app has multiple items, please replace app
with app_item
(Ex: music_song, music_album, ...)
Code Block | ||||
---|---|---|---|---|
|
...
{permalink module='ad.sponsor' id={item-id} section={app_item}}
|
Callbacks
Belows is all required callbacks when integrating your app with Ad Sponsor.
...
Code Block | ||||
---|---|---|---|---|
| ||||
{url link='ad.sponsor' where='feed' section='app' item={item-id}}
|
Note: replace
app
with your item app alias anditem-id
with your item id.
If your app has multiple items, please replace app
with app_item
(Ex: music_song, music_album, ...)
Code Block | ||||
---|---|---|---|---|
|
...
{url link='ad.sponsor' where='feed' section='{app_item}' item={item-id}}
|
Un-sponsor action
To un-sponsor an item, we usually use ajax call
Code Block | ||||
---|---|---|---|---|
| ||||
$.ajaxCall('ad.removeSponsor', 'type_id={app}&item_id=`item-id`', 'GET');
|
Note: don't forget to replace
app
/app_item
andapp-id
Or we can use function deleteSponsor
of class Ad_Service_Process
.
Code Block | ||||
---|---|---|---|---|
|
...
Phpfox::getService('ad.process')->deleteSponsor($iSponsorId, true);
|
Check sponsored item
To check sponsored item, you can use function canSponsoredInFeed
of class Feed_Service_Feed
. This function will return true
if item is sponsored.
Code Block | ||||
---|---|---|---|---|
| ||||
Phpfox::getService('feed')->canSponsoredInFeed({app}, {app-id});
|
...