P
P
Pavel Chuev2016-04-10 19:01:10
PHP
Pavel Chuev, 2016-04-10 19:01:10

How to loop over values ​​from mysql?

There is a need to make reposts every day from different VKontakte groups / publics to your own. Wrote a small code that takes 1 random entry from the wall by filter: not fixed and not reposted from another public.

<?php
$token = '';
$gid = '';
$gid2 = '';
$wall = file_get_contents("https://api.vk.com/method/wall.get?v=5.7&filter=all&owner_id=-".$gid2);
$wall = json_decode($wall);
$wall = $wall->response->items;
$i = mt_rand(1, count($wall));
$x = $wall[$i]->post_type;
$z = $wall[$i]->is_pinned;
if($x == 'post'){
if($z !== 1){
$repost = file_get_contents("https://api.vk.com/method/wall.repost?v=5.7&object=wall-".$gid2."_".$wall[$i]->id."&group_id=".$gid."&access_token=".$token);
$repost = json_decode($repost);
}}
?>

So, reposts should be done every day by brute force (preferably with a small timeout between each in order to avoid attacks from VK. Since in my code it will work with only one id, and there will be 5-10
id publics, I would like to store in mysql by days of the week, i.e. on Monday there are some ids, on Tuesday - others, etc.
How to implement all this on my code?)

Answer the question

In order to leave comments, you need to log in

9 answer(s)
P
Pavel Chuev, 2016-04-10
@AllDecay

UPD

<?php
set_time_limit(600);
$ids = array ("", "", "", "", "", ""); //тут id групп/пабликов, из которых нужно сделать репосты
foreach ($ids as $gid2){
$token = '';
$gid = '';
$wall = file_get_contents("https://api.vk.com/method/wall.get?v=5.7&filter=all&owner_id=-".$gid2);
$wall = json_decode($wall);
$wall = $wall->response->items;
$i = mt_rand(1, count($wall));
$x = $wall[$i]->post_type;
$z = $wall[$i]->is_pinned;
if($x == 'post'){
if($z !== 1){
$repost = file_get_contents("https://api.vk.com/method/wall.repost?v=5.7&object=wall-".$gid2."_".$wall[$i]->id."&group_id=".$gid."&access_token=".$token);
$repost = json_decode($repost);
}}
sleep(30);} //указав sleep выполнился только один репост. В чем может быть дело?
?>

D
D', 2015-03-11
@greygloomy

Whether the author is trolling, or xs ...
In Linux, everything is very simple:
Of all this company, Arch Linux stands apart. Not as geeky as Gentoo, but not as user-friendly as Debian. You can assemble anything from it, but you will need a little more than basic knowledge of Linux.
For those who doubt whether it is worth moving to Linux, I usually answer like this:
The author needs a lot of specific software that will happily work under VirtualBox, but does it make sense then for the author to move?
If you want a simple change of scenery, then it's better to buy a macbook with MacOS (well, almost *nix, too, once there was *sarcasm*).

P
Pavel Shvedov, 2015-03-11
@mmmaaak

MacOSX

S
ShamblerR, 2015-03-11
@ShamblerR

gentoo won't work for you, it's for Linux geeks. This axis is not for the desktop, but rather for experiments.
Unfortunately, you don't have much of a choice.
photoshop in Linux does not work and will not be in the near future, cc6 works quite stably for me, but how suitable it is for professional use remains in question, it’s one thing to sit in it for an hour a month and another from morning to night.
The same goes for everything else.
In fact, I would recommend to you a misplaced BSD by our good friend Steve.
At least the work of the author of the effect and photoshop will be normal in it.
As for flexibility, any niks system is flexible for Windows millions of times.
Custom is everywhere.
As for the registry, I will disappoint it in Linux. And fortunately, such idiotic thoughts about the establishment of the garbage heap of Linuxoids are visited very rarely. (although they visit)
If macOS does not appeal to you, then the choice is even less
ubuntu mint debian, in fact, that's all. The largest community is the most likely that all the hardware will work.
But remember, not all software will run on Linux.
In the end, when opening exe files, the system will politely offer you several options for text editors to open them.
And if there is no full-fledged port on the tench, then there may be problems.

E
Eugene Ki, 2015-03-11
@qqq3

mint. And wine is used to run Windows programs, though not all go correctly

K
Konstantin Kitmanov, 2015-03-11
@k12th

In general, Linux is better suited for coding than for all these artistic things, but...
You can't install Gentoo. Let's start with something simpler, the most newbie-friendly distro is Ubuntu, with a large community.
You will not recompile the kernel, I guarantee you, although this possibility is everywhere.
I personally have never encountered problems with firewood, but in general people complain. It is necessary to google "linux hardware model".
Everything and everywhere is visually customized, but personally it seems to me that KDE is the most pleasant.
Some of the software you listed will probably run under wine, specifically you need to check it , for some there are proven alternatives (GIMP, Blender).
> Tools support (don't know how things are on different distros) GNU
Free utilities that don't work under a free system -- that would be original.

A
Adamos, 2015-03-11
@Adamos

The question is more like a throw-in than a question. Especially requirements Nos. 2 and 4.

O
OnYourLips, 2015-03-11
@OnYourLips

Most of the above requirements are only suitable for OS X.
But this is not Linux.
And, judging by the requirements, Linux will not suit you exactly.

G
garadash, 2015-03-12
@garadash

Build a hackintosh on the right hardware according to the recommendation from tonymac, install branded osx out of the box - it will cost much less than apple, factory and now it's all quite stable. In any case, you don’t lose anything, just from the very beginning, the choice of hardware should be considered - as a bonus, have osx on regular hardware.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question