Successfully publishing to speech.

This commit is contained in:
Paul Kirby 2018-10-25 19:44:08 -05:00
parent c88e927794
commit 54639a7f55
3 changed files with 13 additions and 6 deletions

3
.gitignore vendored
View file

@ -8,3 +8,6 @@
tmp/* tmp/*
!*.gitkeep !*.gitkeep
#Ignore config file
lbry_config.php

View file

@ -56,14 +56,14 @@ class LBRY_Speech
error_log(print_r($attachment, true)); error_log(print_r($attachment, true));
// TODO: set post meta to see if already uploaded // TODO: set post meta to see if already uploaded
$file_url = $attachment->guid; $file_url = get_attached_file($attachment->ID);
$file_url = str_replace(site_url(), '', $file_url); $cfile = new CURLFile($file_url, $attachment->post_mime_type, $attachment->post_name . '.jpg');
$cfile = curl_file_create($file_url, $attachment->post_mime_type, $attachment->post_name);
$params = array( $params = array(
'name' => $attachment->post_name, 'name' => $attachment->post_name,
'file' => $cfile, 'file' => $cfile,
'title' => $attachment->post_title 'title' => $attachment->post_title,
'type' => $attachment->post_mime_type
); );
$result = $this->request('publish', $params); $result = $this->request('publish', $params);
@ -97,8 +97,8 @@ class LBRY_Speech
/** /**
* Sends a cURL request to the Speech URL * Sends a cURL request to the Speech URL
* @param string $method The method to call on the LBRY API * @param string $method The method to call on the Speech API
* @param array $params The Parameters to send the LBRY API Call * @param array $params The Parameters to send the Speech API Call
* @return string The cURL response * @return string The cURL response
*/ */
private function request($method, $params = array()) private function request($method, $params = array())

4
lbry_config.example.php Normal file
View file

@ -0,0 +1,4 @@
<?php
// Define Speech Channel and password
// define(LBRY_SPEECH_CHANNEL, '');
// define(LBRY_SPEECH_CHANNEL_PASSWORD, '');