Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to upload Flickr Images #577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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