Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

New features #34

Closed
wants to merge 5 commits into from
Closed

New features #34

wants to merge 5 commits into from

Conversation

Ghitu
Copy link
Contributor

@Ghitu Ghitu commented Apr 15, 2016

Hello,

I've added a few new features that I needed for one of my projects. If you wish, you can merge them into your repository.

The features are:

Example code

 use Fabiang\Xmpp\Protocol\Register;
 ...

 $options = new Options($chatUrl.':5222');
 $client = new Client($options);
 $options->setUsername($adminUsername)->setPassword($adminPassword);

 $user = new Register;
 $user->setTo($chatUrl)
      ->setFrom($adminUsername.'@'.$chatUrl)
      ->setJabberID($userUsername.'@'.$chatUrl)
      ->setPassword($userPassword);

  $client->send($user);
  $sid = $options->getSid();
  $user->setSID($sid)->setStep('two');
  $client->send($user);
  • vCard support
    At the moment can set only: First Name, Last Name, URL (to user profile), Image

Example code

 use Fabiang\Xmpp\Protocol\vCard;
 ...

 $options = new Options($chatUrl.':5222');
 $client = new Client($options);
 $options->setUsername($userUsername)->setPassword($userPassword);

 $vcard = new vCard;
 $vcard->setFirstname($userFirstName)
            ->setLastname($u->last_name)
            ->setJabberID(strtolower($u->username).'@'.Config::get("app.chat_url"))
            ->setUrl($u->getUserUrl());

 $mime = 'image/jpeg'; // image mime type
 $image = file_get_contents($image_url);
 $vcard->setMime($mime)->setImage(base64_encode($image));

$client->send($vcard);
$client->disconnect();

Example code

 use Fabiang\Xmpp\Protocol\BlockUser;
 ...

$options = new Options($chatUrl.':5222');
$client = new Client($options);

$options->setUsername($userUsername)->setPassword$userPassword);

$blockUser = new BlockUser;
$blockUser->setFrom($userUsername.'@'.$chatUrl)
         ->setJabberID($blockUserUsername.'@'.$chatUrl);
$client->send($blockUser);

$client->disconnect();
 use Fabiang\Xmpp\Protocol\UnblockUser;
 ...

$options = new Options($chatUrl.':5222');
$client = new Client($options);

$options->setUsername($userUsername)->setPassword$userPassword);

$unBlockUser = new UnblockUser;
$unBlockUser ->setJabberID($blockedUserUsername.'@'.$chatUrl);
$client->send($unBlockUser);

$client->disconnect();

Hope this helps
Alin

@ghost
Copy link

ghost commented Jul 10, 2016

👍 I need those features too. @fabiang can you look into this?
@Ghitu Do you plan to add "get" feature?

@Ghitu
Copy link
Contributor Author

Ghitu commented Jul 11, 2016

@varakh I am not planning to add other features for the moment. I can help you with the get if you give me more details.

@ghost
Copy link

ghost commented Jul 11, 2016

@Ghitu Nevermind. As long as this does not get merged I won't need those features either. I will come back to this if it got merged. Thanks anyway.

@fabiang
Copy link
Owner

fabiang commented May 23, 2017

Cherry picked your relevant commit and merged locally. Thanks for the work!

@fabiang fabiang closed this May 23, 2017
@Ghitu
Copy link
Contributor Author

Ghitu commented May 23, 2017

@fabiang Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants