Squashed commit of the following:
commit d198ef5fc3a535b6384f5de33ac41cf8d2bd9a40 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Oct 26 22:00:11 2016 +0100 Add latest bridgy related changes commit b1c72c8f70df03134bea14d2668fb90915fb7853 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Oct 26 19:13:15 2016 +0100 Have links on Facebook commit e99618618ae1fc84081db241d05fd15ce65af66f Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Oct 26 18:15:47 2016 +0100 Add a job to syndicate to facebook commit c37653e2b1a2237172b24dfa3b0bc4da30b52927 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Oct 26 18:15:25 2016 +0100 Fix some typos in the comments commit c65bd20a94478cc1e5832b22d48d824a00411f92 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Oct 26 17:54:13 2016 +0100 Add necessary a links to facilitate bridgy publishing commit b62d3a4daf39ebf8c495f381702a25ed0715e1fe Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Oct 26 17:46:04 2016 +0100 Send webmentions to bridgy in order to syndicate
This commit is contained in:
parent
af7e58b0d1
commit
fafab6e013
5 changed files with 113 additions and 79 deletions
53
app/Jobs/SyndicateToFacebook.php
Normal file
53
app/Jobs/SyndicateToFacebook.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Note;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class SyndicateToFacebook implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $note;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Note $note)
|
||||
{
|
||||
$this->note = $note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Client $guzzle)
|
||||
{
|
||||
//send webmention
|
||||
$response = $guzzle->request(
|
||||
'POST',
|
||||
'https://brid.gy/publish/webmention',
|
||||
[
|
||||
'form_params' => [
|
||||
'source' => $this->note->longurl,
|
||||
'target' => 'https://brid.gy/publish/facebook',
|
||||
],
|
||||
]
|
||||
);
|
||||
//parse for syndication URL
|
||||
if ($response->getStatusCode() == 201) {
|
||||
$json = json_decode((string) $response->getBody());
|
||||
$this->note->facebook_url = $json->url;
|
||||
$this->note->save();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue