Skip to content

Commit

Permalink
Facebook chat is deprecated. Refs #41
Browse files Browse the repository at this point in the history
  • Loading branch information
frost-nzcr4 committed Sep 9, 2016
1 parent 1b54774 commit f650509
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 183 deletions.
10 changes: 1 addition & 9 deletions docs/users/jaxl_instance.rst
Expand Up @@ -17,7 +17,7 @@ Constructor options

#. ``auth_type``

DIGEST-MD5, PLAIN (default), CRAM-MD5, ANONYMOUS, X-FACEBOOK-PLATFORM
DIGEST-MD5, PLAIN (default), CRAM-MD5, ANONYMOUS

#. ``host``
#. ``port``
Expand All @@ -27,14 +27,6 @@ Constructor options

``JAXL_ERROR``, ``JAXL_WARNING``, ``JAXL_NOTICE``, ``JAXL_INFO`` (default), ``JAXL_DEBUG``

#. ``fb_access_token``

required when using X-FACEBOOK-PLATFORM auth mechanism

#. ``fb_app_key``

required when using X-FACEBOOK-PLATFORM auth mechanism

#. ``force_tls``
#. ``stream_context``
#. ``priv_dir``
Expand Down
106 changes: 0 additions & 106 deletions examples/xfacebook_platform_client.php

This file was deleted.

71 changes: 3 additions & 68 deletions jaxl.php
Expand Up @@ -579,56 +579,7 @@ protected function enable_debug_shell()
//
// abstract method implementation
//

protected function send_fb_challenge_response($challenge)
{
$this->send($this->get_fb_challenge_response_pkt($challenge));
}

// refer https://developers.facebook.com/docs/chat/#jabber
public function get_fb_challenge_response_pkt($challenge)
{
$stanza = new JAXLXml('response', NS_SASL);

$challenge = base64_decode($challenge);
$challenge = urldecode($challenge);
parse_str($challenge, $challenge_arr);

$response = http_build_query(array(
'method' => $challenge_arr['method'],
'nonce' => $challenge_arr['nonce'],
'access_token' => $this->cfg['fb_access_token'],
'api_key' => $this->cfg['fb_app_key'],
'call_id' => 0,
'v' => '1.0'
));

$stanza->t(base64_encode($response));
return $stanza;
}

public function wait_for_fb_sasl_response($event, $args)
{
switch ($event) {
case "stanza_cb":
$stanza = $args[0];

if ($stanza->name == 'challenge' && $stanza->ns == NS_SASL) {
$challenge = $stanza->text;
$this->send_fb_challenge_response($challenge);
return "wait_for_sasl_response";
} else {
_debug("got unhandled sasl response, should never happen here");
exit;
}
break;
default:
_debug("not catched $event, should never happen here");
exit;
break;
}
}


// someday this needs to go inside xmpp stream
public function wait_for_cram_md5_response($event, $args)
{
Expand Down Expand Up @@ -733,20 +684,6 @@ public function handle_auth_mechs($stanza, $mechanisms)
if ($pref_auth_exists) {
$mech = $pref_auth;
} else {
// if pref auth doesn't exists, choose one from available mechanisms

foreach ($mechs as $mech => $any) {
// choose X-FACEBOOK-PLATFORM only if fb_access_token config value is available
if ($mech == 'X-FACEBOOK-PLATFORM') {
if (isset($this->cfg['fb_access_token'])) {
break;
}
} else {
// else try first of the available methods

break;
}
}
_error("preferred auth type not supported, trying $mech");
}

Expand All @@ -755,10 +692,8 @@ public function handle_auth_mechs($stanza, $mechanisms)
isset($this->jid) ? $this->jid->to_string() : null,
$this->pass
);

if ($pref_auth == 'X-FACEBOOK-PLATFORM') {
return "wait_for_fb_sasl_response";
} elseif ($pref_auth == 'CRAM-MD5') {

if ($pref_auth == 'CRAM-MD5') {
return "wait_for_cram_md5_response";
} elseif ($pref_auth == 'SCRAM-SHA-1') {
return "wait_for_scram_sha1_response";
Expand Down

0 comments on commit f650509

Please sign in to comment.