Skip to content

Conversation

FraGoTe
Copy link

@FraGoTe FraGoTe commented Jul 4, 2021

I'm adding a feature to upload Flickr images directly from this lib.

Usage:

$flickrService = $serviceFactory->createService('Flickr', $credentials, $storage, [],
    new OAuth\Common\Http\Uri\Uri('https://up.flickr.com/services/upload/')
);

$multipart = '--------------------------'  .  microtime(true);
$fileName = __DIR__  .  '/img.png';
$fileBin = file_get_contents($fileName);

$content =  "--" . $multipart."\r\n".
"Content-Disposition: form-data; name=\"photo\"; filename=\"".basename($fileName)."\"\r\n".
"Content-Type: application/png\r\n\r\n".
$fileBin."\r\n";

// signal end of request (note the trailing "--")
$content .= "--" . $multipart . "--\r\n";

$req = $flickrService->request(
  '/',
  'POST',
  $content,
  ['Content-Type' => 'multipart/form-data; boundary=' . $multipart]
);

$x = simplexml_load_string($req);
$photoId = (string)$x->photoid;
var_dump('<pre>', $x, (string)$x->photoid);

@FraGoTe FraGoTe changed the title #576 Support to upload Flickr Images Jul 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant