Custom Effects Integration

To add a new effect to the SolidOpinion widget installed on your website, follow the steps below:

Step 1. Log in to your SolidOpinion account.



Step 2
. Go to the "Your sites" tab:



Step 3. Enter the shortname of the site you need.



Step 4. Find the website you want and click the "Settings" button.  



Step
 5. Select the "Game rules" tab on the admin panel.



Step 6.  Scroll down the page until you see the "Custom effects" option:  



  Step 7. To create an action click the "Create" button.



Step 8.  Enter the name of the action in the popup field: 



Step 9. Also you can:
  • Select the "+" option and set a certain amount of points, so they can be given as bonus to a user, who applies this action.

  • Select the "-" option and set a certain amount of points a user should pay to apply this action.


Step 10. To see your custom effect code click the "Display code" link.






Step 11. To edit your effect click the "Edit" icon.



Step 12. To remove your effect click the "delete" icon.



Step 13. Make sure to click the "Save Changes" button.



Step 14.  Go to the "Filters" tab and add your server IP to the site settings.  .



Integration part:

Use the SolidOpinion SDK: http://api.solidopinion.com/api/dev/sosdk.php

Create the js script with the getPoints(code) function which sends the AJAX request with the effect code  :
 function getPoints(code) {
   jQuery.post(
      myajax.url,
       {
           action : 'add_effect',
           effectcode: code,
           usercode: SOSDK.usercode
       },
       function( response ) {
           console.log( response );
       }
   );
 }  
 ( function( $ ) {
      // Set customm effect to any events on your site
      // For example: click to button with id custom_effect
 $( document ).on( 'click', '#custom_effect', function( e ) {  
getPoints('YOUR_EFFECT_CODE');
} );
 } )( jQuery ); }     // For example: click to button with id custom_effect
 $( document ).on( 'click', '#custom_effect', function( e ) {  
getPoints('YOUR_EFFECT_CODE');
} );
 } )( jQuery ); }    
Add this code to your php functions: 
function myajax_submit() {
   if(isset($_POST['usercode'])) {

       $ch = curl_init();

       $postData = 'sitename=YOUR_SOLIDOPINION_SHORTNAME&usercode='.$_POST['usercode'].'&effectcode='.$_POST['effectcode'];
       curl_setopt($ch, CURLOPT_URL,'api.solidopinion.com/api/user/adduserpoints');
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
       curl_setopt($ch, CURLOPT_POST, count($postData));
       curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

       $output = curl_exec($ch);

       $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
       if ($httpCode == 200) {
            echo("OK! api.solidopinion.com/api/user/adduserpoints/".$postData);
       }
       else {
           echo("FAIL! ".$httpCode." ".$output);
       }

       curl_close($ch);

   }
 exit;  
 }    

Happy commenting!
SolidOpinion

Feedback and Knowledge Base