📜 ⬆️ ⬇️

Appendix "harmonious couple." Second wind!

I already wrote about how for the social network "In Contact" by us ( charly , vandriichuk ) the application "Harmonious Couple" was created.
After some time, it turned out that no one needs serious applications. Ie, the application that is looking for a harmonious couple according to the ascendant, turned out to be unclaimed.

As one girl said, “Why do I need such a pessimistic app? I want entertaining! ”

Then it was decided to increase the functionality of the application. Add some fun moments.

')

What did we do?



We have added the section "Fun". In this section, you can send an audio joke or flash card to a friend / friend (you can select all of this from the list, add your own accompanying text).

Audio jokes and cards are comic in nature (for example, you can throw a tomato at a friend or make a declaration of love). It's nice to get them :)

But sending this kind of message involves sending users a notification that they have received a new audio message or card.

Here we got the first pitfall.

To send notifications, Secure application interaction with API is required.
Protected interaction of the application with the API, as opposed to the standard, takes place without client participation and is carried out between the VKontakte API and its own remote developer server.

The application interacts with the VKontakte API by creating an HTTP request (POST or GET) to api.vkontakte.ru/api.php .


The documentation on this issue, I think, is not sufficient. It was necessary by trial and error, day and night to search for a solution. Since I am a flasher, not a php progger, I had to dig a little bit in the manuals and chat with some people. As a result, a script was written every other day (thanks to the people from the VKontakte developers club).

I am citing the php script code that receives the users id and the message that they need to show in the notification.

<?php

$uids=$_POST['notify_uids'];
$send_m=$_POST['notify_message'];

$api = array();
$api['api_id'] = 'ID '; // ID
$api['method'] = "secure.sendNotification";
$api['random'] = mt_rand(100000,9999999); //
$api['timestamp'] = time(); // unixtime , 150
$api['v'] = "2.0";
$api['uids'] = $uids;
$api['message'] = $send_m;

ksort($api); // , ..
$api_sig = " , ";
$sig_src = '';
foreach($api as $api_key => $api_value) $sig_src .= ($api_key.'='.$api_value);
$sig_src .= $api_sig;
$api['sig'] = md5($sig_src);

$finish_string='';
foreach($api as $api_key => $api_value) $finish_string .= ($api_key.'='.$api_value.'&');

$finish_string= substr($finish_string, 0, strlen($finish_string)-1);

$api_request = 'api.vkontakte.ru/api.php?'.$finish_string;

$url = "http://api.vkontakte.ru/api.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $finish_string); // add POST fields
$result = curl_exec($ch); // run the whole process
curl_close($ch);
echo $result;

?>




In addition to the section with jokes some more goodies were added.
The characteristic of the ascendant was extended (added sections of life, car, food, relationships, career, etc.).
Some moments of the application have been completely redone.

And as a result, a few days after the completion of all work on the application, users began to add it to themselves and use it directly.

The number of unique views increased by 3 times (from a modest 70 unique per day to a modest 210).

Although it is not very much, but still nice! There is an incentive to work on.

A little bit about earnings


You can earn on your application! But for this it must be popular.
Voices are being earned (currency in vkontakte), which are displayed through payment systems or sold on the black market.

There are two main ways to earn votes:


Here with the targeted advertising there was a second pitfall .

Unbeknownst to all, the administration of VKontakte removed the advertisement that was displayed on the left below the menu on the application pages. If earlier it was necessary to simply allow in the settings to show ads on the page of your own application, now you need to send a request to the API inside the application to get such advertising. The method used is not described in the VK API Documentation.

They speak about him only in the developers club.
Ie, if you are a novice and have not made a single application, then you will never know about it.

We are starting to test the new getAds method.
With it, you can receive up to 10 targeted advertising modules aimed at the current user.
The method has a single count parameter that can be used to limit the number of ads returned. By default, this parameter is 10.

Starting July 20, all applications that have third-party advertising will be forced to switch to using targeted VK ads.


The advertising module consists of several fields:
title
descrition
photo
link

And the link will not work if it is not processed in this way:

link = String(xml.link).split('&').join('&');


A line of code finds the html & symbol and changes it to &.

Conclusion


I hope this post was interesting for you. I tried to reveal a few points that are hard to find on the Internet.

Finally, I want to wish you to find your Harmonious couple! And do not talk about your friends. They also want to get funny :)

Source: https://habr.com/ru/post/67559/


All Articles