Skip to content

Instantly share code, notes, and snippets.

@byteg
Created June 14, 2019 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byteg/0b682c2b7154bed41a172919408f6061 to your computer and use it in GitHub Desktop.
Save byteg/0b682c2b7154bed41a172919408f6061 to your computer and use it in GitHub Desktop.
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