Created
June 14, 2019 12:03
-
-
Save byteg/0b682c2b7154bed41a172919408f6061 to your computer and use it in GitHub Desktop.
Like4u Vk API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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