forked from friendica/deprecated-addons
Removed many deprecated addons
This commit is contained in:
parent
8ea198a97e
commit
1b7283c72b
247 changed files with 28554 additions and 0 deletions
254
appnet/test/ADNRecipes.php
Normal file
254
appnet/test/ADNRecipes.php
Normal file
|
@ -0,0 +1,254 @@
|
|||
<?php
|
||||
/**
|
||||
* ADNRecipes.php
|
||||
* App.net PHP library
|
||||
* https://github.com/jdolitsky/AppDotNetPHP
|
||||
*
|
||||
* This class contains some simple recipes for publishing to App.net.
|
||||
*/
|
||||
|
||||
require_once "AppDotNet.php";
|
||||
|
||||
class ADNRecipe {
|
||||
protected $_adn = null;
|
||||
|
||||
public function __construct() {
|
||||
$this->_adn = new AppDotNet(null, null);
|
||||
}
|
||||
|
||||
public function setAccessToken($access_token) {
|
||||
$this->_adn->setAccessToken($access_token);
|
||||
}
|
||||
}
|
||||
|
||||
class ADNBroadcastMessageBuilder extends ADNRecipe {
|
||||
// stores the channel ID for this message
|
||||
private $_channel_id = null;
|
||||
|
||||
// stores the headline
|
||||
private $_headline = null;
|
||||
|
||||
// stores the body text
|
||||
private $_text = null;
|
||||
|
||||
// should we parse markdown links?
|
||||
private $_parseMarkdownLinks = false;
|
||||
|
||||
// should we parse URLs out of the text body?
|
||||
private $_parseLinks = false;
|
||||
|
||||
// stores the read more link
|
||||
private $_readMoreLink = null;
|
||||
|
||||
// stores the photo filename
|
||||
private $_photo = null;
|
||||
|
||||
// stores the attachment filename
|
||||
private $_attachment = null;
|
||||
|
||||
/**
|
||||
* Sets the destination channel ID. Required.
|
||||
* @param string $channel_id The App.net Channel ID to send to. Get this
|
||||
* from the web publisher tools if you don't have one.
|
||||
*/
|
||||
public function setChannelID($channel_id) {
|
||||
$this->_channel_id = $channel_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChannelID() {
|
||||
return $this->_channel_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the broadcast headline. This string shows up in the push
|
||||
* notifications which are sent to mobile apps, and is the title
|
||||
* displayed in the UI.
|
||||
* @param string $headline A short string for a headline.
|
||||
*/
|
||||
public function setHeadline($headline) {
|
||||
$this->_headline = $headline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHeadline() {
|
||||
return $this->_headline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the broadcast text. This string shows up as a description
|
||||
* on the broadcast detail page and in the "card" view in the
|
||||
* mobile apps. Can contain links.
|
||||
* @param string $text Broadcast body text.
|
||||
*/
|
||||
public function setText($text) {
|
||||
$this->_text = $text;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a flag which allows links to be parsed out of body text in
|
||||
* [Markdown](http://daringfireball.net/projects/markdown/)
|
||||
* format.
|
||||
* @param bool $parseMarkdownLinks Parse markdown links.
|
||||
*/
|
||||
public function setParseMarkdownLinks($parseMarkdownLinks) {
|
||||
$this->_parseMarkdownLinks = $parseMarkdownLinks;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParseMarkdownLinks() {
|
||||
return $this->_parseMarkdownLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a flag which causes bare URLs in body text to be linkified.
|
||||
* @param bool $parseLinks Parse links.
|
||||
*/
|
||||
public function setParseLinks($parseLinks) {
|
||||
$this->_parseLinks = $parseLinks;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParseLinks() {
|
||||
return $this->_parseLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URL the broadcast should link to.
|
||||
* @param string $readMoreLink Read more link URL.
|
||||
*/
|
||||
public function setReadMoreLink($readMoreLink) {
|
||||
$this->_readMoreLink = $readMoreLink;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReadMoreLink() {
|
||||
return $this->_readMoreLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the filename of a photo associated with a broadcast.
|
||||
* Probably requires the php-imagick extension. File will be
|
||||
* uploaded to App.net.
|
||||
* @param string $photo Photo filename.
|
||||
*/
|
||||
public function setPhoto($photo) {
|
||||
$this->_photo = $photo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhoto() {
|
||||
return $this->_photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the filename of a attachment associated with a broadcast.
|
||||
* File will be uploaded to App.net.
|
||||
* @param string $attachment Attachment filename.
|
||||
*/
|
||||
public function setAttachment($attachment) {
|
||||
$this->_attachment = $attachment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAttachment() {
|
||||
return $this->_attachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the built-up broadcast.
|
||||
*/
|
||||
public function send() {
|
||||
$parseLinks = $this->_parseLinks || $this->_parseMarkdownLinks;
|
||||
$message = array(
|
||||
"annotations" => array(),
|
||||
"entities" => array(
|
||||
"parse_links" => $parseLinks,
|
||||
"parse_markdown_links" => $this->_parseMarkdownLinks,
|
||||
),
|
||||
);
|
||||
|
||||
if (isset($this->_photo)) {
|
||||
$photoFile = $this->_adn->createFile($this->_photo, array(
|
||||
type => "com.github.jdolitsky.appdotnetphp.photo",
|
||||
));
|
||||
|
||||
$message["annotations"][] = array(
|
||||
"type" => "net.app.core.oembed",
|
||||
"value" => array(
|
||||
"+net.app.core.file" => array(
|
||||
"file_id" => $photoFile["id"],
|
||||
"file_token" => $photoFile["file_token"],
|
||||
"format" => "oembed",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->_attachment)) {
|
||||
if (isset($this->_attachment)) {
|
||||
$attachmentFile = $this->_adn->createFile($this->_attachment, array(
|
||||
type => "com.github.jdolitsky.appdotnetphp.attachment",
|
||||
));
|
||||
|
||||
$message["annotations"][] = array(
|
||||
"type" => "net.app.core.oembed",
|
||||
"value" => array(
|
||||
"+net.app.core.file" => array(
|
||||
"file_id" => $attachmentFile["id"],
|
||||
"file_token" => $attachmentFile["file_token"],
|
||||
"format" => "metadata",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->_text)) {
|
||||
$message["text"] = $this->_text;
|
||||
} else {
|
||||
$message["machine_only"] = true;
|
||||
}
|
||||
|
||||
if (isset($this->_headline)) {
|
||||
$message["annotations"][] = array(
|
||||
"type" => "net.app.core.broadcast.message.metadata",
|
||||
"value" => array(
|
||||
"subject" => $this->_headline,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->_readMoreLink)) {
|
||||
$message["annotations"][] = array(
|
||||
"type" => "net.app.core.crosspost",
|
||||
"value" => array(
|
||||
"canonical_url" => $this->_readMoreLink,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_adn->createMessage($this->_channel_id, $message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
94
appnet/test/ConsumeStream.php
Executable file
94
appnet/test/ConsumeStream.php
Executable file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
require_once 'AppDotNet.php';
|
||||
require_once 'EZsettings.php';
|
||||
|
||||
$app = new AppDotNet($app_clientId,$app_clientSecret);
|
||||
|
||||
// You need an app token to consume the stream, get the token returned by App.net
|
||||
// (this also sets the token)
|
||||
$token = $app->getAppAccessToken();
|
||||
|
||||
// getting a 400 error
|
||||
// 1. first check to make sure you set your app_clientId & app_clientSecret correctly
|
||||
// if that doesn't fix it, try this
|
||||
// 2. It's possible you have hit your stream limit (5 stream per app)
|
||||
// uncomment this to clear all the streams you've previously created
|
||||
//$app->deleteAllStreams();
|
||||
|
||||
// create a stream
|
||||
// if you already have a stream you can skip this step
|
||||
// this stream is going to consume posts and stars (but not follows)
|
||||
$stream = $app->createStream(array('post','star','user_follow'));
|
||||
|
||||
// you might want to save $stream['endpoint'] or $stream['id'] for later so
|
||||
// you don't have to re-create the stream
|
||||
print "stream id [".$stream['id']."]\n";
|
||||
//$stream = $app->getStream(XXX);
|
||||
|
||||
// we need to create a callback function that will do something with posts/stars
|
||||
// when they're received from the stream. This function should accept one single
|
||||
// parameter that will be the php object containing the meta / data for the event.
|
||||
|
||||
/*
|
||||
[meta] => Array
|
||||
(
|
||||
[timestamp] => 1352147672891
|
||||
[type] => post/star/etc...
|
||||
[id] => 1399341
|
||||
)
|
||||
// data is as you would expect it
|
||||
*/
|
||||
function handleEvent($event) {
|
||||
global $counters;
|
||||
$json=json_encode($event['data']);
|
||||
$counters[$event['meta']['type']]++;
|
||||
switch ($event['meta']['type']) {
|
||||
case 'post':
|
||||
print $event['meta']['is_deleted']?'p':'P';
|
||||
break;
|
||||
case 'star':
|
||||
print $event['meta']['is_deleted']?'_':'*';
|
||||
break;
|
||||
case 'user_follow':
|
||||
print $event['meta']['is_deleted']?'f':'F';
|
||||
break;
|
||||
case 'stream_marker':
|
||||
print $event['meta']['is_deleted']?'/':'=';
|
||||
break;
|
||||
case 'message':
|
||||
print $event['meta']['is_deleted']?'m':'M';
|
||||
break;
|
||||
case 'channel':
|
||||
print $event['meta']['is_deleted']?'c':'C';
|
||||
break;
|
||||
case 'channel_subscription':
|
||||
print $event['meta']['is_deleted']?'f':'F';
|
||||
break;
|
||||
default:
|
||||
print "Unknwon type [".$event['meta']['type']."]\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// register that function as the stream handler
|
||||
$app->registerStreamFunction('handleEvent');
|
||||
|
||||
// open the stream for reading
|
||||
$app->openStream($stream['endpoint']);
|
||||
|
||||
// now we want to process the stream. We have two options. If all we're doing
|
||||
// in this script is processing the stream, we can just call:
|
||||
// $app->processStreamForever();
|
||||
// otherwise you can create a loop, and call $app->processStream($milliseconds)
|
||||
// intermittently, like:
|
||||
while (true) {
|
||||
$counters=array('post'=>0,'star'=>0,'user_follow'=>0,'stream_marker'=>0,'message'=>0,'channel'=>0,'channel_subscription'=>0);
|
||||
// now we're going to process the stream for awhile (60 seconds)
|
||||
$app->processStream(60*1000000);
|
||||
echo "\n";
|
||||
// show some stats
|
||||
echo date('H:i')." [",$counters['post'],"]posts [",$counters['star'],"]stars [",$counters['user_follow'],"]follow [",$counters['stream_marker'],"]mrkrs [",$counters['message'],"]msgs /min\n";
|
||||
// then do something else...
|
||||
}
|
||||
?>
|
235
appnet/test/EZAppDotNet.php
Normal file
235
appnet/test/EZAppDotNet.php
Normal file
|
@ -0,0 +1,235 @@
|
|||
<?php
|
||||
/**
|
||||
* EZAppDotNet.php
|
||||
* Class for easy web development
|
||||
* https://github.com/jdolitsky/AppDotNetPHP
|
||||
*
|
||||
* This class does as much of the grunt work as possible in helping you to
|
||||
* access the App.net API. In theory you don't need to know anything about
|
||||
* oAuth, tokens, or all the ugly details of how it works, it should "just
|
||||
* work".
|
||||
*
|
||||
* Note this class assumes you're running a web site, and you'll be
|
||||
* accessing it via a web browser (it expects to be able to do things like
|
||||
* cookies and sessions). If you're not using a web browser in your App.net
|
||||
* application, or you want more fine grained control over what's being
|
||||
* done for you, use the included AppDotNet class, which does much
|
||||
* less automatically.
|
||||
*/
|
||||
|
||||
// comment these two lines out in production
|
||||
//error_reporting(E_ALL);
|
||||
//ini_set('display_errors', 1);
|
||||
|
||||
//require_once 'EZsettings.php';
|
||||
require_once 'AppDotNet.php';
|
||||
|
||||
// comment this out if session is started elsewhere
|
||||
//session_start();
|
||||
|
||||
class EZAppDotNet extends AppDotNet {
|
||||
|
||||
private $_callbacks = array();
|
||||
private $_autoShutdownStreams = array();
|
||||
|
||||
public function __construct($clientId=null,$clientSecret=null) {
|
||||
global $app_clientId,$app_clientSecret;
|
||||
|
||||
// if client id wasn't passed, and it's in the settings.php file, use it from there
|
||||
if (!$clientId && isset($app_clientId)) {
|
||||
|
||||
// if it's still the default, warn them
|
||||
if ($app_clientId == 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') {
|
||||
throw new AppDotNetException('You must change the values defined in EZsettings.php');
|
||||
}
|
||||
|
||||
$clientId = $app_clientId;
|
||||
$clientSecret = $app_clientSecret;
|
||||
}
|
||||
|
||||
// call the parent with the variables we have
|
||||
parent::__construct($clientId,$clientSecret);
|
||||
|
||||
// set up ez streaming
|
||||
$this->registerStreamFunction(array($this,'streamEZCallback'));
|
||||
|
||||
// make sure we cleanup/destroy any streams when we exit
|
||||
register_shutdown_function(array($this,'stopStreaming'));
|
||||
}
|
||||
|
||||
public function getAuthUrl($redirectUri=null,$scope=null) {
|
||||
global $app_redirectUri,$app_scope;
|
||||
|
||||
if (is_null($redirectUri)) {
|
||||
$redirectUri = $app_redirectUri;
|
||||
}
|
||||
if (is_null($scope)) {
|
||||
$scope = $app_scope;
|
||||
}
|
||||
return parent::getAuthUrl($redirectUri,$scope);
|
||||
}
|
||||
|
||||
// user login
|
||||
public function setSession($cookie=0,$callback=null) {
|
||||
|
||||
if (!isset($callback)) {
|
||||
global $app_redirectUri;
|
||||
$cb=$app_redirectUri;
|
||||
} else {
|
||||
$cb=$callback;
|
||||
}
|
||||
|
||||
// try and set the token the original way (eg: if they're logging in)
|
||||
$token = $this->getAccessToken($cb);
|
||||
|
||||
// if that didn't work, check to see if there's an existing token stored somewhere
|
||||
if (!$token) {
|
||||
$token = $this->getSession();
|
||||
}
|
||||
|
||||
$_SESSION['AppDotNetPHPAccessToken']=$token;
|
||||
|
||||
// if they want to stay logged in via a cookie, set the cookie
|
||||
if ($token && $cookie) {
|
||||
$cookie_lifetime = time()+(60*60*24*7);
|
||||
setcookie('AppDotNetPHPAccessToken',$token,$cookie_lifetime);
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
// check if user is logged in
|
||||
public function getSession() {
|
||||
|
||||
// first check for cookie
|
||||
if (isset($_COOKIE['AppDotNetPHPAccessToken']) && $_COOKIE['AppDotNetPHPAccessToken'] != 'expired') {
|
||||
$this->setAccessToken($_COOKIE['AppDotNetPHPAccessToken']);
|
||||
return $_COOKIE['AppDotNetPHPAccessToken'];
|
||||
}
|
||||
|
||||
// else check the session for the token (from a previous page load)
|
||||
else if (isset($_SESSION['AppDotNetPHPAccessToken'])) {
|
||||
$this->setAccessToken($_SESSION['AppDotNetPHPAccessToken']);
|
||||
return $_SESSION['AppDotNetPHPAccessToken'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// log the user out
|
||||
public function deleteSession() {
|
||||
// clear the session
|
||||
unset($_SESSION['AppDotNetPHPAccessToken']);
|
||||
|
||||
// unset the cookie
|
||||
setcookie('AppDotNetPHPAccessToken', null, 1);
|
||||
|
||||
// clear the access token
|
||||
$this->setAccessToken(null);
|
||||
|
||||
// done!
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a callback function to be called whenever an event of a certain
|
||||
* type is received from the app.net streaming API. Your function will recieve
|
||||
* a PHP associative array containing an app.net object. You must register at
|
||||
* least one callback function before starting to stream (otherwise your data
|
||||
* would simply be discarded). You can register multiple event types and even
|
||||
* multiple functions per event (just call this method as many times as needed).
|
||||
* If you register multiple functions for a single event, each will be called
|
||||
* every time an event of that type is received.
|
||||
*
|
||||
* Note you should not be doing any significant processing in your callback
|
||||
* functions. Doing so could cause your scripts to fall behind the stream and
|
||||
* risk getting disconnected. Ideally your callback functions should simply
|
||||
* drop the data into a file or database to be collected and processed by
|
||||
* another program.
|
||||
* @param string $type The type of even your callback would like to recieve.
|
||||
* At time of writing the possible options are 'post', 'star', 'user_follow'.
|
||||
*/
|
||||
public function registerStreamCallback($type,$callback) {
|
||||
switch ($type) {
|
||||
case 'post':
|
||||
case 'star':
|
||||
case 'user_follow':
|
||||
if (!array_key_exists($type,$this->_callbacks)) {
|
||||
$this->_callbacks[$type] = array();
|
||||
}
|
||||
$this->_callbacks[$type][] = $callback;
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
throw new AppDotNetException('Unknown callback type: '.$type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the easy way to start streaming. Register some callback functions
|
||||
* using registerCallback(), then call startStreaming(). Every time the stream
|
||||
* gets sent a type of object you have a callback for, your callback function(s)
|
||||
* will be called with the proper data. When your script exits the streams will
|
||||
* be cleaned up (deleted).
|
||||
*
|
||||
* Do not use this method if you want to spread out streams across multiple
|
||||
* processes or multiple servers, since the first script that exits/crashes will
|
||||
* delete the streams for everyone else. Instead use createStream() and openStream().
|
||||
* @return true
|
||||
* @see AppDotNetStream::stopStreaming()
|
||||
* @see AppDotNetStream::createStream()
|
||||
* @see AppDotNetStream::openStream()
|
||||
*/
|
||||
public function startStreaming() {
|
||||
// only listen for object types that we have registered callbacks for
|
||||
if (!$this->_callbacks) {
|
||||
throw new AppDotNetException('You must register at least one callback function before calling startStreaming');
|
||||
}
|
||||
// if there's already a stream running, don't allow another
|
||||
if ($this->_currentStream) {
|
||||
throw new AppDotNetException('There is already a stream being consumed, only one stream can be consumed per AppDotNetStream instance');
|
||||
}
|
||||
$stream = $this->createStream(array_keys($this->_callbacks));
|
||||
// when the script exits, delete this stream (if it's still around)
|
||||
$this->_autoShutdownStreams[] = $response['id'];
|
||||
// start consuming
|
||||
$this->openStream($response['id']);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the easy way to stop streaming and cleans up the no longer needed stream.
|
||||
* This method will be called automatically if you started streaming using
|
||||
* startStreaming().
|
||||
*
|
||||
* Do not use this method if you want to spread out streams across multiple
|
||||
* processes or multiple servers, since it will delete the streams for everyone
|
||||
* else. Instead use closeStream().
|
||||
* @return true
|
||||
* @see AppDotNetStream::startStreaming()
|
||||
* @see AppDotNetStream::deleteStream()
|
||||
* @see AppDotNetStream::closeStream()
|
||||
*/
|
||||
public function stopStreaming() {
|
||||
$this->closeStream();
|
||||
// delete any auto streams
|
||||
foreach ($this->_autoShutdownStreams as $streamId) {
|
||||
$this->deleteStream($streamId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function used to make your streaming easier. I hope.
|
||||
*/
|
||||
protected function streamEZCallback($type,$data) {
|
||||
// if there are defined callbacks for this object type, then...
|
||||
if (array_key_exists($type,$this->_callbacks)) {
|
||||
// loop through the callbacks notifying each one in turn
|
||||
foreach ($this->_callbacks[$type] as $callback) {
|
||||
call_user_func($callback,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
25
appnet/test/EZsettings.php
Normal file
25
appnet/test/EZsettings.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
// change these values to your own in order to use EZAppDotNet
|
||||
$app_clientId = 'js4qF6UN4fwXTK87Ax9Bjf3DhEQuK5hA';
|
||||
$app_clientSecret = 'Z4hsLHh82d5cQAwNVD2uZtNg3WqFxLXF';
|
||||
|
||||
// this must be one of the URLs defined in your App.net application settings
|
||||
$app_redirectUri = 'https://pirati.ca/addon/appnetpost/appnet.php';
|
||||
|
||||
// An array of permissions you're requesting from the user.
|
||||
// As a general rule you should only request permissions you need for your app.
|
||||
// By default all permissions are commented out, meaning you'll have access
|
||||
// to their basic profile only. Uncomment the ones you need.
|
||||
$app_scope = array(
|
||||
'basic', // See basic user info (default, required: may be given if not specified)
|
||||
'stream', // Read the user's personalized stream
|
||||
// 'email', // Access the user's email address
|
||||
'write_post', // Post on behalf of the user
|
||||
// 'follow', // Follow and unfollow other users
|
||||
'public_messages', // Send and receive public messages as this user
|
||||
'messages', // Send and receive public and private messages as this user
|
||||
// 'update_profile', // Update a user’s name, images, and other profile information
|
||||
// 'files', // Manage a user’s files. This is not needed for uploading files.
|
||||
// 'export', // Export all user data (shows a warning)
|
||||
);
|
106
appnet/test/backup/appnet.php
Normal file
106
appnet/test/backup/appnet.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
/*
|
||||
* login_with_buffer.php
|
||||
*
|
||||
* @(#) $Id: login_with_buffer.php,v 1.1 2014/03/17 09:45:08 mlemos Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Get the http.php file from http://www.phpclasses.org/httpclient
|
||||
*/
|
||||
require('http.php');
|
||||
require('oauth_client.php');
|
||||
|
||||
$client = new oauth_client_class;
|
||||
$client->debug = true;
|
||||
$client->debug_http = true;
|
||||
$client->server = '';
|
||||
|
||||
$client->oauth_version = '2.0';
|
||||
$client->dialog_url = 'https://account.app.net/oauth/authenticate?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&response_type=code&state={STATE}';
|
||||
$client->access_token_url = 'https://account.app.net/oauth/access_token';
|
||||
|
||||
$client->redirect_uri = 'https://'.$_SERVER['HTTP_HOST'].
|
||||
dirname(strtok($_SERVER['REQUEST_URI'],'?')).'/appnet.php';
|
||||
|
||||
$client->client_id = 'js4qF6UN4fwXTK87Ax9Bjf3DhEQuK5hA'; $application_line = __LINE__;
|
||||
$client->client_secret = 'Z4hsLHh82d5cQAwNVD2uZtNg3WqFxLXF ';
|
||||
|
||||
if(strlen($client->client_id) == 0
|
||||
|| strlen($client->client_secret) == 0)
|
||||
die('Please create an application in App.net Apps page '.
|
||||
'https://bufferapp.com/developers/apps/create '.
|
||||
' and in the line '.$application_line.
|
||||
' set the client_id to Client ID and client_secret with Client'.
|
||||
' Secret');
|
||||
|
||||
//$client->access_token = 'AQAAAAAACzfmWzVa5o69CFJrV-fBt9PLkV9sd9_0BnnHTI02_NGvvsZDCgz-38eA5_yAgu9AwaFcUzFp0qdCj4y2svy6qUl42g';
|
||||
|
||||
/* API permissions
|
||||
*/
|
||||
$client->scope = '';
|
||||
if(($success = $client->Initialize()))
|
||||
{
|
||||
if(($success = $client->Process()))
|
||||
{
|
||||
if(strlen($client->access_token))
|
||||
{;
|
||||
$success = $client->CallAPI(
|
||||
'https://api.app.net/users/me',
|
||||
'GET', array(), array('FailOnAccessError'=>true, 'RequestBody'=>true), $user);
|
||||
/*
|
||||
$params["text"] = "Nur ein Test";
|
||||
$params["profile_ids"][] = "52b844df9db82271330000b8";
|
||||
//$params["profile_ids"][] = "5280e86b5b3c91d77b0000dd";
|
||||
//$params["profile_ids"][] = "52b844ed9db82271330000bc";
|
||||
//$params["profile_ids"][] = "52b8463d9db822db340000e1";
|
||||
$params["shorten"] = false;
|
||||
$params["now"] = false;
|
||||
print_r($params);
|
||||
$success = $client->CallAPI(
|
||||
'https://api.bufferapp.com/1/updates/create.json',
|
||||
'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
|
||||
*/
|
||||
}
|
||||
}
|
||||
$success = $client->Finalize($success);
|
||||
}
|
||||
if($client->exit)
|
||||
exit;
|
||||
|
||||
if($success)
|
||||
{
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>App.net OAuth client results</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
echo '<h1>', HtmlSpecialChars($user->name),
|
||||
' you have logged in successfully with App.net!</h1>';
|
||||
echo '<pre>', HtmlSpecialChars(print_r($user, 1)), '</pre>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>OAuth client error</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>OAuth client error</h1>
|
||||
<pre>Error: <?php echo HtmlSpecialChars($client->error); ?></pre>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
2122
appnet/test/backup/http.php
Normal file
2122
appnet/test/backup/http.php
Normal file
File diff suppressed because it is too large
Load diff
2486
appnet/test/backup/oauth_client.php
Normal file
2486
appnet/test/backup/oauth_client.php
Normal file
File diff suppressed because it is too large
Load diff
272
appnet/test/backup/oauth_configuration.json
Normal file
272
appnet/test/backup/oauth_configuration.json
Normal file
|
@ -0,0 +1,272 @@
|
|||
{
|
||||
"version": "$Id: oauth_configuration.json,v 1.6 2014/04/12 10:24:01 mlemos Exp $",
|
||||
"comments": [
|
||||
"The servers entry should be an object with a list of object",
|
||||
"entries, one for each server type. The server object entry name is",
|
||||
"the name of the server type. Each server entry is an object with",
|
||||
"some mandatory properties: oauth_version, dialog_url,",
|
||||
"access_token_url and request_token_url (just for Oauth 1.0 and",
|
||||
"1.0a). Check the OAuth client class for the complete list of server",
|
||||
"properties."
|
||||
],
|
||||
"servers":
|
||||
{
|
||||
"37Signals":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://launchpad.37signals.com/authorization/new?type=web_server&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&state={STATE}&scope={SCOPE}",
|
||||
"access_token_url": "https://launchpad.37signals.com/authorization/token?type=web_server"
|
||||
},
|
||||
|
||||
"Amazon":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://www.amazon.com/ap/oa?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&response_type=code&state={STATE}",
|
||||
"access_token_url": "https://api.amazon.com/auth/o2/token"
|
||||
},
|
||||
|
||||
"Bitbucket":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "https://bitbucket.org/!api/1.0/oauth/request_token",
|
||||
"dialog_url": "https://bitbucket.org/!api/1.0/oauth/authenticate",
|
||||
"access_token_url": "https://bitbucket.org/!api/1.0/oauth/access_token",
|
||||
"url_parameters": false
|
||||
},
|
||||
|
||||
"Box":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://www.box.com/api/oauth2/authorize?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&state={STATE}&scope={SCOPE}",
|
||||
"offline_dialog_url": "https://www.box.com/api/oauth2/authorize?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&state={STATE}&access_type=offline&approval_prompt=force",
|
||||
"access_token_url": "https://www.box.com/api/oauth2/token"
|
||||
},
|
||||
|
||||
"Buffer":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://bufferapp.com/oauth2/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&state={STATE}&scope={SCOPE}",
|
||||
"access_token_url": "https://api.bufferapp.com/1/oauth2/token.json"
|
||||
},
|
||||
|
||||
"Dailymotion":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://api.dailymotion.com/oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&state={STATE}&scope={SCOPE}",
|
||||
"access_token_url": "https://api.dailymotion.com/oauth/token"
|
||||
},
|
||||
|
||||
"Discogs":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "http://api.discogs.com/oauth/request_token",
|
||||
"dialog_url": "http://www.discogs.com/oauth/authorize",
|
||||
"access_token_url": "http://api.discogs.com/oauth/access_token"
|
||||
},
|
||||
|
||||
"Disqus":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://disqus.com/api/oauth/2.0/authorize/?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}",
|
||||
"access_token_url": "https://disqus.com/api/oauth/2.0/access_token/"
|
||||
},
|
||||
|
||||
"Dropbox":
|
||||
{
|
||||
"oauth_version": "1.0",
|
||||
"request_token_url": "https://api.dropbox.com/1/oauth/request_token",
|
||||
"dialog_url": "https://www.dropbox.com/1/oauth/authorize",
|
||||
"access_token_url": "https://api.dropbox.com/1/oauth/access_token",
|
||||
"authorization_header": false
|
||||
},
|
||||
|
||||
"Dropbox2":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://www.dropbox.com/1/oauth2/authorize?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}",
|
||||
"access_token_url": "https://www.dropbox.com/1/oauth2/token"
|
||||
},
|
||||
|
||||
"Etsy":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "https://openapi.etsy.com/v2/oauth/request_token?scope={SCOPE}",
|
||||
"dialog_url": "automatic",
|
||||
"access_token_url": "https://openapi.etsy.com/v2/oauth/access_token"
|
||||
},
|
||||
|
||||
"Eventful":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "http://eventful.com/oauth/request_token",
|
||||
"dialog_url": "http://eventful.com/oauth/authorize",
|
||||
"access_token_url": "http://eventful.com/oauth/access_token",
|
||||
"authorization_header": false,
|
||||
"url_parameters": true,
|
||||
"token_request_method": "POST"
|
||||
},
|
||||
|
||||
"Evernote":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "https://sandbox.evernote.com/oauth",
|
||||
"dialog_url": "https://sandbox.evernote.com/OAuth.action",
|
||||
"access_token_url": "https://sandbox.evernote.com/oauth",
|
||||
"url_parameters": true,
|
||||
"authorization_header": false
|
||||
},
|
||||
|
||||
"Fitbit":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "http://api.fitbit.com/oauth/request_token",
|
||||
"dialog_url": "http://api.fitbit.com/oauth/authorize",
|
||||
"access_token_url": "http://api.fitbit.com/oauth/access_token"
|
||||
},
|
||||
|
||||
"Flickr":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "http://www.flickr.com/services/oauth/request_token",
|
||||
"dialog_url": "http://www.flickr.com/services/oauth/authorize?perms={SCOPE}",
|
||||
"access_token_url": "http://www.flickr.com/services/oauth/access_token",
|
||||
"authorization_header": false
|
||||
},
|
||||
|
||||
"Foursquare":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://foursquare.com/oauth2/authorize?client_id={CLIENT_ID}&scope={SCOPE}&response_type=code&redirect_uri={REDIRECT_URI}&state={STATE}",
|
||||
"access_token_url": "https://foursquare.com/oauth2/access_token",
|
||||
"access_token_parameter": "oauth_token"
|
||||
},
|
||||
|
||||
"Google1":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"dialog_url": "https://www.google.com/accounts/OAuthAuthorizeToken",
|
||||
"access_token_url": "https://www.google.com/accounts/OAuthGetAccessToken",
|
||||
"request_token_url": "https://www.google.com/accounts/OAuthGetRequestToken?scope={SCOPE}"
|
||||
},
|
||||
|
||||
"Instagram":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://api.instagram.com/oauth/authorize/?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&response_type=code&state={STATE}",
|
||||
"access_token_url": "https://api.instagram.com/oauth/access_token"
|
||||
},
|
||||
|
||||
"Rdio":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "http://api.rdio.com/oauth/request_token",
|
||||
"dialog_url": "https://www.rdio.com/oauth/authorize",
|
||||
"access_token_url": "http://api.rdio.com/oauth/access_token"
|
||||
},
|
||||
|
||||
"Reddit":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://ssl.reddit.com/api/v1/authorize?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}",
|
||||
"offline_dialog_url": "https://ssl.reddit.com/api/v1/authorize?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}&duration=permanent",
|
||||
"access_token_url": "https://ssl.reddit.com/api/v1/access_token",
|
||||
"access_token_authentication": "basic"
|
||||
},
|
||||
|
||||
"RightSignature":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "https://rightsignature.com/oauth/request_token",
|
||||
"dialog_url": "https://rightsignature.com/oauth/authorize",
|
||||
"access_token_url": "https://rightsignature.com/oauth/access_token",
|
||||
"authorization_header": false
|
||||
},
|
||||
|
||||
"Salesforce":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}",
|
||||
"access_token_url": "https://login.salesforce.com/services/oauth2/token",
|
||||
"default_access_token_type": "Bearer",
|
||||
"store_access_token_response": true
|
||||
},
|
||||
|
||||
"Scoop.it":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "https://www.scoop.it/oauth/request",
|
||||
"dialog_url": "https://www.scoop.it/oauth/authorize",
|
||||
"access_token_url": "https://www.scoop.it/oauth/access",
|
||||
"authorization_header": false
|
||||
},
|
||||
|
||||
"StockTwits":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://api.stocktwits.com/api/2/oauth/authorize?client_id={CLIENT_ID}&response_type=code&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}",
|
||||
"access_token_url": "https://api.stocktwits.com/api/2/oauth/token"
|
||||
},
|
||||
|
||||
"SurveyMonkey":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://api.surveymonkey.net/oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&state={STATE}&api_key={API_KEY}&scope={SCOPE}",
|
||||
"access_token_url": "https://api.surveymonkey.net/oauth/token?api_key={API_KEY}"
|
||||
},
|
||||
|
||||
"Tumblr":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "http://www.tumblr.com/oauth/request_token",
|
||||
"dialog_url": "http://www.tumblr.com/oauth/authorize",
|
||||
"access_token_url": "http://www.tumblr.com/oauth/access_token"
|
||||
},
|
||||
|
||||
"Vimeo":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://api.vimeo.com/oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&state={STATE}&scope={SCOPE}",
|
||||
"access_token_url": "https://api.vimeo.com/oauth/access_token"
|
||||
},
|
||||
|
||||
"VK":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://oauth.vk.com/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}",
|
||||
"access_token_url": "https://oauth.vk.com/access_token"
|
||||
},
|
||||
|
||||
"Withings":
|
||||
{
|
||||
"oauth_version": "1.0",
|
||||
"request_token_url": "https://oauth.withings.com/account/request_token",
|
||||
"dialog_url": "https://oauth.withings.com/account/authorize",
|
||||
"access_token_url": "https://oauth.withings.com/account/access_token",
|
||||
"authorization_header": false
|
||||
},
|
||||
|
||||
"Wordpress":
|
||||
{
|
||||
"oauth_version": "2.0",
|
||||
"dialog_url": "https://public-api.wordpress.com/oauth2/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&state={STATE}&scope={SCOPE}",
|
||||
"access_token_url": "https://public-api.wordpress.com/oauth2/token"
|
||||
},
|
||||
|
||||
"Xero":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "https://api.xero.com/oauth/RequestToken",
|
||||
"dialog_url": "https://api.xero.com/oauth/Authorize",
|
||||
"access_token_url": "https://api.xero.com/oauth/AccessToken"
|
||||
},
|
||||
|
||||
"XING":
|
||||
{
|
||||
"oauth_version": "1.0a",
|
||||
"request_token_url": "https://api.xing.com/v1/request_token",
|
||||
"dialog_url": "https://api.xing.com/v1/authorize",
|
||||
"access_token_url": "https://api.xing.com/v1/access_token",
|
||||
"authorization_header": false
|
||||
}
|
||||
}
|
||||
}
|
BIN
appnet/test/master.zip
Normal file
BIN
appnet/test/master.zip
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue