Commit 384b17da by Bagus Pambudi

autopost alia

parent e3a753ae
......@@ -134,24 +134,36 @@ class PostController extends Controller
public function share($data, $request)
{
$setting = webprofilesetting();
$autoPost = $this->autoPostRepo->get();
if ($request->hasFile('thumbnail')) {
$img = $request->file('thumbnail')->getRealPath();
} else {
$img = null;
}
$title = html_entity_decode($data['title']);
$url = $this->shorterUrl(url('post/'.$data['slug']));
$keys = $data['keys'];
$olhashtag = explode(', ', str_replace([', ', ','], ', ', $keys));
$hashtag = '#unesa #unesaterkini ';
foreach ($olhashtag as $value) {
$hashtag .= '#'.trim($value).' ';
}
$client = new Client([
'headers' => [
'Accept' => 'application/json',
// 'Authorization' => 'Bearer ' . session('token')
],
'form_params' => ['url' => url('post/'.$data['slug'])]
]);
$result1 = $client->post('https://alia.unesa.ac.id/api/posts');
$value = json_decode($result1->getBody()->getContents(), true);
// $setting = webprofilesetting();
// $autoPost = $this->autoPostRepo->get();
// if ($request->hasFile('thumbnail')) {
// $img = $request->file('thumbnail')->getRealPath();
// } else {
// $img = null;
// }
// $title = html_entity_decode($data['title']);
// $url = $this->shorterUrl(url('post/'.$data['slug']));
// $keys = $data['keys'];
// $olhashtag = explode(', ', str_replace([', ', ','], ', ', $keys));
// $hashtag = '#unesa #unesaterkini ';
// foreach ($olhashtag as $value) {
// $hashtag .= '#'.trim($value).' ';
// }
// dd($autoPost);
foreach ($autoPost as $value) {
//Social Share Facebook
......@@ -182,16 +194,7 @@ class PostController extends Controller
$client = new Client([
'headers' => [
'Accept' => 'application/json',
// 'Authorization' => 'Bearer ' . session('token')
],
'form_params' => ['url' => url('post/'.$data['slug'])]
]);
$result1 = $client->post('https://alia.unesa.ac.id/api/posts');
$value = json_decode($result1->getBody()->getContents(), true);
dd($value);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment