📜 ⬆️ ⬇️

We combine twitter.com and vkontakte.ru (php - version)

Inspired by the post http://habrahabr.ru/blogs/python/59236/ .
After reading the above post, suggested that not everyone can use a home computer for such purposes (for example, because it is not always on). But many of us have php hosting, which also supports cron. To warm up wrote this script.

When writing used:
twitter API downloaded here
vkontakte API that you wrote yourself. The script code is as follows:

<?
include 'twitter.class.php';
include 'vkontakte.class.php';
include 'config.php';

$twitter = new twitter();

$twitter->username = $twitterUser;
$twitter->password = $twitterPassword;

$statusTwitter = $twitter->userTimeline()->status->text;

$vk = new VkontakteAPI($vkontakteEmail, $vkontaktePassword);
$vk->auth();

$statusVkontakte = $vk->getStatus();

if ($statusTwitter != $statusVkontakte)
{
$vk->setStatus($statusTwitter);
}
?>


Total need to upload it to the folder on the hosting, set the account settings in the config.php file, which has
following view:
<?
$twitterUser = 'pupkin';
$twitterPassword = 'temp';

$vkontakteEmail = 'pupkin@yandex.ru';
$vkontaktePassword = 'temp';
?>

. And in principle, the script is ready to use.
')
I apologize for the “undocumentedness” of my code, I think everything is clear here, but I will still document a bit of free time. I accept questions and suggestions for the development of the script. As well as possible bugs that I will try to rule as soon as possible.

The full archive with the API can be downloaded here: www.radmus.net/downloads/twitter2vkontakte.zip

Enjoy using! =)

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


All Articles