mirror of
https://github.com/openvk/openvk
synced 2025-01-11 02:19:39 +03:00
VKAPI: Geo support (not tested idk)
This commit is contained in:
parent
8d66711ada
commit
22ab724ab4
1 changed files with 25 additions and 1 deletions
|
@ -111,6 +111,18 @@ final class Wall extends VKAPIRequestHandler
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$geo = [];
|
||||||
|
|
||||||
|
if($post->getGeo()) {
|
||||||
|
$geoarray = $post->getGeo();
|
||||||
|
|
||||||
|
$geo = [
|
||||||
|
"coordinates" => $geoarray["lat"] . " " . $geoarray["lng"],
|
||||||
|
"showmap" => 1,
|
||||||
|
"type" => "point"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$items[] = (object)[
|
$items[] = (object)[
|
||||||
"id" => $post->getVirtualId(),
|
"id" => $post->getVirtualId(),
|
||||||
"from_id" => $from_id,
|
"from_id" => $from_id,
|
||||||
|
@ -127,6 +139,7 @@ final class Wall extends VKAPIRequestHandler
|
||||||
"is_pinned" => $post->isPinned(),
|
"is_pinned" => $post->isPinned(),
|
||||||
"is_explicit" => $post->isExplicit(),
|
"is_explicit" => $post->isExplicit(),
|
||||||
"attachments" => $attachments,
|
"attachments" => $attachments,
|
||||||
|
"geo" => $geo,
|
||||||
"post_source" => $post_source,
|
"post_source" => $post_source,
|
||||||
"comments" => (object)[
|
"comments" => (object)[
|
||||||
"count" => $post->getCommentsCount(),
|
"count" => $post->getCommentsCount(),
|
||||||
|
@ -379,7 +392,7 @@ final class Wall extends VKAPIRequestHandler
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function post(string $owner_id, string $message = "", int $from_group = 0, int $signed = 0, string $attachments = ""): object
|
function post(string $owner_id, string $message = "", int $from_group = 0, int $signed = 0, string $attachments = "", float $latitude, float $longitude): object
|
||||||
{
|
{
|
||||||
$this->requireUser();
|
$this->requireUser();
|
||||||
$this->willExecuteWriteAction();
|
$this->willExecuteWriteAction();
|
||||||
|
@ -420,6 +433,12 @@ final class Wall extends VKAPIRequestHandler
|
||||||
if(empty($message) && empty($attachments))
|
if(empty($message) && empty($attachments))
|
||||||
$this->fail(100, "Required parameter 'message' missing.");
|
$this->fail(100, "Required parameter 'message' missing.");
|
||||||
|
|
||||||
|
$geo = array(
|
||||||
|
"name" => null,
|
||||||
|
"lat" => $latitude,
|
||||||
|
"lng" => $longitude,
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$post = new Post;
|
$post = new Post;
|
||||||
$post->setOwner($this->getUser()->getId());
|
$post->setOwner($this->getUser()->getId());
|
||||||
|
@ -428,6 +447,11 @@ final class Wall extends VKAPIRequestHandler
|
||||||
$post->setContent($message);
|
$post->setContent($message);
|
||||||
$post->setFlags($flags);
|
$post->setFlags($flags);
|
||||||
$post->setApi_Source_Name($this->getPlatform());
|
$post->setApi_Source_Name($this->getPlatform());
|
||||||
|
if ($geo) {
|
||||||
|
$post->setGeo(json_encode($geo));
|
||||||
|
$post->setGeo_Lat($geo["lat"]);
|
||||||
|
$post->setGeo_Lon($geo["lng"]);
|
||||||
|
}
|
||||||
$post->save();
|
$post->save();
|
||||||
} catch(\LogicException $ex) {
|
} catch(\LogicException $ex) {
|
||||||
$this->fail(100, "One of the parameters specified was missing or invalid");
|
$this->fail(100, "One of the parameters specified was missing or invalid");
|
||||||
|
|
Loading…
Reference in a new issue