use php arrays for syndicate-to properties
This commit is contained in:
parent
9fe3a8ff07
commit
1c4bf54da4
2 changed files with 7 additions and 3 deletions
|
@ -100,6 +100,7 @@ function micropub_post($endpoint, $params, $access_token) {
|
||||||
$post = http_build_query(array_merge(array(
|
$post = http_build_query(array_merge(array(
|
||||||
'h' => 'entry'
|
'h' => 'entry'
|
||||||
), $params));
|
), $params));
|
||||||
|
$post = preg_replace('/%5B[0-9]+%5D/', '%5B%5D', $post);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||||
|
@ -145,6 +146,7 @@ function get_syndication_targets(&$user) {
|
||||||
if(is_array($r['data']['syndicate-to'])) {
|
if(is_array($r['data']['syndicate-to'])) {
|
||||||
$targetURLs = $r['data']['syndicate-to'];
|
$targetURLs = $r['data']['syndicate-to'];
|
||||||
} elseif(is_string($r['data']['syndicate-to'])) {
|
} elseif(is_string($r['data']['syndicate-to'])) {
|
||||||
|
// support comma separated as a fallback
|
||||||
$targetURLs = preg_split('/, ?/', $r['data']['syndicate-to']);
|
$targetURLs = preg_split('/, ?/', $r['data']['syndicate-to']);
|
||||||
} else {
|
} else {
|
||||||
$targetURLs = array();
|
$targetURLs = array();
|
||||||
|
@ -153,10 +155,12 @@ function get_syndication_targets(&$user) {
|
||||||
foreach($targetURLs as $t) {
|
foreach($targetURLs as $t) {
|
||||||
// If the syndication target doesn't have a scheme, add http
|
// If the syndication target doesn't have a scheme, add http
|
||||||
if(!preg_match('/^http/', $t))
|
if(!preg_match('/^http/', $t))
|
||||||
$t = 'http://' . $t;
|
$t2 = 'http://' . $t;
|
||||||
|
else
|
||||||
|
$t2 = $t;
|
||||||
|
|
||||||
// Parse the target expecting it to be a URL
|
// Parse the target expecting it to be a URL
|
||||||
$url = parse_url($t);
|
$url = parse_url($t2);
|
||||||
|
|
||||||
// If there's a host, and the host contains a . then we can assume there's a favicon
|
// If there's a host, and the host contains a . then we can assume there's a favicon
|
||||||
// parse_url will parse strings like http://twitter into an array with a host of twitter, which is not resolvable
|
// parse_url will parse strings like http://twitter into an array with a host of twitter, which is not resolvable
|
||||||
|
|
|
@ -126,7 +126,7 @@ $(function(){
|
||||||
location: $("#note_location").val(),
|
location: $("#note_location").val(),
|
||||||
category: $("#note_category").val(),
|
category: $("#note_category").val(),
|
||||||
slug: $("#note_slug").val(),
|
slug: $("#note_slug").val(),
|
||||||
'syndicate-to': syndications.join(',')
|
'syndicate-to': syndications
|
||||||
}, function(data){
|
}, function(data){
|
||||||
var response = JSON.parse(data);
|
var response = JSON.parse(data);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue