Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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_app

Can members of this user group mark a an app as Sponsor without paying fee?

2

app_sponsor_price

How much is does the sponsor space worth for app? This works in a CPM basis.

3

auto_publish_sponsored_app

After the user has purchased a sponsored space, should the app be published right away? <br>If If set to No, the admin will have to approve each new purchased sponsored app space before it is shown in the site.

 

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 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
actionscript3
actionscript3

{permalink module='ad.sponsor' id={item-id}} section_={{itemapp}}

...

 

Note:

replace

{{{{

app

}}}}

with

your

item

app

alias

and

{{{

item-id

}}}

with

your

item

id.

If your app has multiple items, please replace

...

app

...

with

...

app_item

...

(Ex: music_song, music_album, ...)

 

Code Block
actionscript3
actionscript3

...

{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 app_item)

Description

1

getToSponsorInfo

getToSponsorInfo{{itemItem}}

Get info of sponsor item

2

deleteSponsorItem

deleteSponsorItem{{itemItem}}

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{{itemItem}}

Callback when sponsor is published, mark your item as sponsored

4

getLink

getLink{{itemItem}}

Get url of your sponsor item

...

Sponsor in feed depends on 4 user group settings of Feed app Feed below.

#

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.

...

Code Block
actionscript3
actionscript3

{url link='ad.sponsor' where='feed' section='{{app}}' item={item-id}}

...

 

Note:

replace

{{{{

app

}}}}

with

your

item

app

alias

and

{{{

item-id

}}}

with

your

item

id.

If your app has multiple items, please replace

...

app

...

with

...

app_item

...

(Ex: music_song, music_album, ...)

 

Code Block
actionscript3
actionscript3

...

{url link='ad.sponsor' where='feed' section='{

...

app_item}

...

' item={item-id}}

...

Un-sponsor action

To unsponsor un-sponsor an item, we usually use ajax call

Code Block
javascript
javascript

$.ajaxCall('ad.removeSponsor', 'type_id={{app}}&item_id={item`item-id}id`', 'GET');

 

Note: don't forget to replace {{app}}/{{app_item}} and {{app-id}}

Or we can use function deleteSponsor of class Ad_Service_Process.

 

Code Block
php
php

...

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
php
php

Phpfox::getService('feed')->canSponsoredInFeed({{app}}, {{app-id}});

Note: don't forget to replace {{app}}/{{app_item}} and {{app-id}}