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

Create or update contact photo (example request) #22

Closed
baaskoen opened this issue Apr 20, 2016 · 5 comments
Closed

Create or update contact photo (example request) #22

baaskoen opened this issue Apr 20, 2016 · 5 comments

Comments

@baaskoen
Copy link

Could you make an example in the docs on how to set or update a contact photo?

Help is much appreciated!

@Garethp
Copy link
Owner

Garethp commented Apr 20, 2016

Will get around to this today or tomorrow

@baaskoen
Copy link
Author

Do you have an idea on when this will be implemented?

@Garethp
Copy link
Owner

Garethp commented Apr 26, 2016

Sorry for the delay, I've been sick lately. Here's the documentation on how to do it

@Garethp
Copy link
Owner

Garethp commented Apr 26, 2016

You could also do it as just one giant array, but I dislike that. Here's how you would do that

<?php

use jamesiarmes\PEWS\Contacts\ContactsAPI as API;
use jamesiarmes\PEWS\API\Type;

$api = API::withUsernameAndPassword('server', 'username', 'password');

$contact = $api->getContacts()[0];
$api->getClient()->CreateAttachment(array(
    'ParentItemId' => $contact->getItemId()->toArray(),
    'Attachments' => array('FileAttachment' => array(
        'Name' => 'Avatar',
        'Content' => file_get_contents("./github.png"),
        'ContentType' => 'image/png',
        'IsContactPhoto' => true
    ))
));

But honestly, I want to be moving away from doing everything in arrays. In the future, In the next release, I'll be making an $api->createAttachment($itemId, $attachment) function, but I don't have an ETA on that

@Garethp Garethp closed this as completed Apr 26, 2016
@baaskoen
Copy link
Author

I hope you get better soon. Thank you very much!

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

No branches or pull requests

2 participants