Sponsorship is one of the most important features of the phpFox platform. Purpose of this tutorial is provide some guideline for developers who want to integrate this feature with their apps.
Sponsor in app's block
User group settings
# |
Name |
Description |
---|---|---|
1 |
can_sponsor_ |
Can members of this user group mark a |
2 |
|
How much is 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.
Sponsor without fee
When can_sponsor_app
is Yes, user 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
.
Purchase sponsor
Integrate below url to redirect your user to sponsor page.
{permalink module='ad.sponsor' id={item-id} section={app}}
If your app has multiple items, please replaceNote: replace
app
with your item app alias anditem-id
with your item id.
app
with app_item
(Ex: music_song, music_album, ...)
{permalink module='ad.sponsor' id={item-id} section={app_item}}
Callbacks
Belows is all required callbacks when integrating your app with Ad Sponsor.
# |
Function name (Single item) |
Function name (Multiple item |
Description |
---|---|---|---|
1 |
getToSponsorInfo |
getToSponsorInfo{{Item}} |
Get info of sponsor item |
2 |
deleteSponsorItem |
deleteSponsorItem{{Item}} |
Callback when sponsor is deleted in AdminCP, you can use this callback to set that item as un-sponsor so that user can sponsor it again |
3 |
enableSponsor |
enableSponsor{{Item}} |
Callback when sponsor is published, mark your item as sponsored |
4 |
getLink |
getLink{{Item}} |
Get url of your sponsor item |
Sponsor in feed
User group settings
Sponsor in feed depends on 4 user group settings of Feed app.
# |
Name |
Description |
---|---|---|
1 |
feed.can_purchase_sponsor |
Can members of this user group purchase a sponsored ad space? |
2 |
feed.can_sponsor_feed |
Can members of this user group define a feed as sponsored without paying? |
3 |
feed.feed_sponsor_price |
How much does it cost to sponsor a feed post? This works in a CPM basis |
4 |
feed.auto_publish_sponsored_item |
After the user has purchased a sponsored space, should the item be published right away? If set to false, the admin will have to approve each new purchased sponsored event space before it is shown in the site. |
Integration
Sponsor action
Integrate below url to redirect user to sponsor in feed.
{url link='ad.sponsor' where='feed' section='app' item={item-id}}
If your app has multiple items, please replaceNote: replace
app
with your item app alias anditem-id
with your item id.
app
with app_item
(Ex: music_song, music_album, ...)
{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
$.ajaxCall('ad.removeSponsor', 'type_id={app}&item_id=`item-id`', 'GET');
Or we can use functionNote: don't forget to replace
app
/app_item
andapp-id
deleteSponsor
of class Ad_Service_Process
.
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 sponsored.
Phpfox::getService('feed')->canSponsoredInFeed({app}, {app-id});
Note: don't forget to replace
app
/app_item
andapp-id