Skip to content

Instantly share code, notes, and snippets.

@byteg

byteg/api.php

Created Jun 14, 2019
Embed
What would you like to do?
Like4u Vk API example
<?php
$url = "https://vk.com/feed?w=wall-72973891_77233";
$token = "";
$postdata = array("token" => $token,
"task" => array(
"kind" => "1",
"title" => "SOME TITLE",
"url" => $url,
"members_count" => "111",
"cost" => "1",
"tag_list" => "",
"sex" => "",
"age_min" => "",
"age_max" => "",
"friends_count" => "",
"country" => "",
"city_text" => "",
"city" => "",
"has_avatar" => "1"
),
"task_limit" => array(
"minute_1" => "",
"minutes_5" => "",
"hour_1" => "",
"hours_4" => "",
"day_1" => ""
)
);
$data_string = json_encode($postdata);
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "https://like4u.ru/tasks.json");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
echo $output;
// close curl resource to free up system resources
curl_close($ch);
$obj=json_decode($output);
$apid = $obj->id;
$err = $obj->error;
if(isset($err) || !isset($apid)) {
echo '{"error":"'.$err.'"}';
} else {
echo '{"order":"'.$apid.'"}';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.