Removed many deprecated addons
This commit is contained in:
parent
8ea198a97e
commit
1b7283c72b
247 changed files with 28554 additions and 0 deletions
1647
appnet/AppDotNet.php
Normal file
1647
appnet/AppDotNet.php
Normal file
|
|
@ -0,0 +1,1647 @@
|
|||
<?php
|
||||
/**
|
||||
* AppDotNet.php
|
||||
* App.net PHP library
|
||||
* https://github.com/jdolitsky/AppDotNetPHP
|
||||
*
|
||||
* This class handles a lower level type of access to App.net. It's ideal
|
||||
* for command line scripts and other places where you want full control
|
||||
* over what's happening, and you're at least a little familiar with oAuth.
|
||||
*
|
||||
* Alternatively you can use the EZAppDotNet class which automatically takes
|
||||
* care of a lot of the details like logging in, keeping track of tokens,
|
||||
* etc. EZAppDotNet assumes you're accessing App.net via a browser, whereas
|
||||
* this class tries to make no assumptions at all.
|
||||
*/
|
||||
class AppDotNet {
|
||||
|
||||
protected $_baseUrl = 'https://alpha-api.app.net/stream/0/';
|
||||
protected $_authUrl = 'https://account.app.net/oauth/';
|
||||
|
||||
private $_authPostParams=array();
|
||||
|
||||
// stores the access token after login
|
||||
private $_accessToken = null;
|
||||
|
||||
// stores the App access token if we have it
|
||||
private $_appAccessToken = null;
|
||||
|
||||
// stores the user ID returned when fetching the auth token
|
||||
private $_user_id = null;
|
||||
|
||||
// stores the username returned when fetching the auth token
|
||||
private $_username = null;
|
||||
|
||||
// The total number of requests you're allowed within the alloted time period
|
||||
private $_rateLimit = null;
|
||||
|
||||
// The number of requests you have remaining within the alloted time period
|
||||
private $_rateLimitRemaining = null;
|
||||
|
||||
// The number of seconds remaining in the alloted time period
|
||||
private $_rateLimitReset = null;
|
||||
|
||||
// The scope the user has
|
||||
private $_scope = null;
|
||||
|
||||
// token scopes
|
||||
private $_scopes=array();
|
||||
|
||||
// debug info
|
||||
private $_last_request = null;
|
||||
private $_last_response = null;
|
||||
|
||||
// ssl certification
|
||||
private $_sslCA = null;
|
||||
|
||||
// the callback function to be called when an event is received from the stream
|
||||
private $_streamCallback = null;
|
||||
|
||||
// the stream buffer
|
||||
private $_streamBuffer = '';
|
||||
|
||||
// stores the curl handler for the current stream
|
||||
private $_currentStream = null;
|
||||
|
||||
// stores the curl multi handler for the current stream
|
||||
private $_multiStream = null;
|
||||
|
||||
// stores the number of failed connects, so we can back off multiple failures
|
||||
private $_connectFailCounter = 0;
|
||||
|
||||
// stores the most recent stream url, so we can re-connect when needed
|
||||
private $_streamUrl = null;
|
||||
|
||||
// keeps track of the last time we've received a packet from the api, if it's too long we'll reconnect
|
||||
private $_lastStreamActivity = null;
|
||||
|
||||
// stores the headers received when connecting to the stream
|
||||
private $_streamHeaders = null;
|
||||
|
||||
// response meta max_id data
|
||||
private $_maxid = null;
|
||||
|
||||
// response meta min_id data
|
||||
private $_minid = null;
|
||||
|
||||
// response meta more data
|
||||
private $_more = null;
|
||||
|
||||
// response stream marker data
|
||||
private $_last_marker = null;
|
||||
|
||||
// strip envelope response from returned value
|
||||
private $_stripResponseEnvelope=true;
|
||||
|
||||
// if processing stream_markers or any fast stream, decrease $sleepFor
|
||||
public $streamingSleepFor=20000;
|
||||
|
||||
/**
|
||||
* Constructs an AppDotNet PHP object with the specified client ID and
|
||||
* client secret.
|
||||
* @param string $client_id The client ID you received from App.net when
|
||||
* creating your app.
|
||||
* @param string $client_secret The client secret you received from
|
||||
* App.net when creating your app.
|
||||
*/
|
||||
public function __construct($client_id,$client_secret) {
|
||||
$this->_clientId = $client_id;
|
||||
$this->_clientSecret = $client_secret;
|
||||
|
||||
// if the digicert certificate exists in the same folder as this file,
|
||||
// remember that fact for later
|
||||
if (file_exists(dirname(__FILE__).'/DigiCertHighAssuranceEVRootCA.pem')) {
|
||||
$this->_sslCA = dirname(__FILE__).'/DigiCertHighAssuranceEVRootCA.pem';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not to strip Envelope Response (meta) information
|
||||
* This option will be deprecated in the future. Is it to allow
|
||||
* a stepped migration path between code expecting the old behavior
|
||||
* and new behavior. When not stripped, you still can use the proper
|
||||
* method to pull the meta information. Please start converting your code ASAP
|
||||
*/
|
||||
public function includeResponseEnvelope() {
|
||||
$this->_stripResponseEnvelope=false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the proper Auth URL for the user to visit and either grant
|
||||
* or not access to your app. Usually you would place this as a link for
|
||||
* the user to client, or a redirect to send them to the auth URL.
|
||||
* Also can be called after authentication for additional scopes
|
||||
* @param string $callbackUri Where you want the user to be directed
|
||||
* after authenticating with App.net. This must be one of the URIs
|
||||
* allowed by your App.net application settings.
|
||||
* @param array $scope An array of scopes (permissions) you wish to obtain
|
||||
* from the user. Currently options are stream, email, write_post, follow,
|
||||
* messages, and export. If you don't specify anything, you'll only receive
|
||||
* access to the user's basic profile (the default).
|
||||
*/
|
||||
public function getAuthUrl($callback_uri,$scope=null) {
|
||||
|
||||
// construct an authorization url based on our client id and other data
|
||||
$data = array(
|
||||
'client_id'=>$this->_clientId,
|
||||
'response_type'=>'code',
|
||||
'redirect_uri'=>$callback_uri,
|
||||
);
|
||||
|
||||
$url = $this->_authUrl;
|
||||
if ($this->_accessToken) {
|
||||
$url .= 'authorize?';
|
||||
} else {
|
||||
$url .= 'authenticate?';
|
||||
}
|
||||
$url .= $this->buildQueryString($data);
|
||||
|
||||
if ($scope) {
|
||||
$url .= '&scope='.implode('+',$scope);
|
||||
}
|
||||
|
||||
// return the constructed url
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this after they return from the auth page, or anytime you need the
|
||||
* token. For example, you could store it in a database and use
|
||||
* setAccessToken() later on to return on behalf of the user.
|
||||
*/
|
||||
public function getAccessToken($callback_uri) {
|
||||
// if there's no access token set, and they're returning from
|
||||
// the auth page with a code, use the code to get a token
|
||||
if (!$this->_accessToken && isset($_GET['code']) && $_GET['code']) {
|
||||
|
||||
// construct the necessary elements to get a token
|
||||
$data = array(
|
||||
'client_id'=>$this->_clientId,
|
||||
'client_secret'=>$this->_clientSecret,
|
||||
'grant_type'=>'authorization_code',
|
||||
'redirect_uri'=>$callback_uri,
|
||||
'code'=>$_GET['code']
|
||||
);
|
||||
|
||||
// try and fetch the token with the above data
|
||||
$res = $this->httpReq('post',$this->_authUrl.'access_token', $data);
|
||||
|
||||
// store it for later
|
||||
$this->_accessToken = $res['access_token'];
|
||||
$this->_username = $res['username'];
|
||||
$this->_user_id = $res['user_id'];
|
||||
}
|
||||
|
||||
// return what we have (this may be a token, or it may be nothing)
|
||||
return $this->_accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the scope of current token to see if it has required scopes
|
||||
* has to be done after a check
|
||||
*/
|
||||
public function checkScopes($app_scopes) {
|
||||
if (!count($this->_scopes)) {
|
||||
return -1; // _scope is empty
|
||||
}
|
||||
$missing=array();
|
||||
foreach($app_scopes as $scope) {
|
||||
if (!in_array($scope,$this->_scopes)) {
|
||||
if ($scope=='public_messages') {
|
||||
// messages works for public_messages
|
||||
if (in_array('messages',$this->_scopes)) {
|
||||
// if we have messages in our scopes
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$missing[]=$scope;
|
||||
}
|
||||
}
|
||||
// identify the ones missing
|
||||
if (count($missing)) {
|
||||
// do something
|
||||
return $missing;
|
||||
}
|
||||
return 0; // 0 missing
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access token (eg: after retrieving it from offline storage)
|
||||
* @param string $token A valid access token you're previously received
|
||||
* from calling getAccessToken().
|
||||
*/
|
||||
public function setAccessToken($token) {
|
||||
$this->_accessToken = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deauthorize the current token (delete your authorization from the API)
|
||||
* Generally this is useful for logging users out from a web app, so they
|
||||
* don't get automatically logged back in the next time you redirect them
|
||||
* to the authorization URL.
|
||||
*/
|
||||
public function deauthorizeToken() {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'token');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an app access token from the app.net API. This allows you
|
||||
* to access the API without going through the user access flow if you
|
||||
* just want to (eg) consume global. App access tokens are required for
|
||||
* some actions (like streaming global). DO NOT share the return value
|
||||
* of this function with any user (or save it in a cookie, etc). This
|
||||
* is considered secret info for your app only.
|
||||
* @return string The app access token
|
||||
*/
|
||||
public function getAppAccessToken() {
|
||||
|
||||
// construct the necessary elements to get a token
|
||||
$data = array(
|
||||
'client_id'=>$this->_clientId,
|
||||
'client_secret'=>$this->_clientSecret,
|
||||
'grant_type'=>'client_credentials',
|
||||
);
|
||||
|
||||
// try and fetch the token with the above data
|
||||
$res = $this->httpReq('post',$this->_authUrl.'access_token', $data);
|
||||
|
||||
// store it for later
|
||||
$this->_appAccessToken = $res['access_token'];
|
||||
$this->_accessToken = $res['access_token'];
|
||||
$this->_username = null;
|
||||
$this->_user_id = null;
|
||||
|
||||
return $this->_accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of requests you're allowed within the
|
||||
* alloted time period.
|
||||
* @see getRateLimitReset()
|
||||
*/
|
||||
public function getRateLimit() {
|
||||
return $this->_rateLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of requests you have remaining within the alloted time period
|
||||
* @see getRateLimitReset()
|
||||
*/
|
||||
public function getRateLimitRemaining() {
|
||||
return $this->_rateLimitRemaining;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of seconds remaining in the alloted time period.
|
||||
* When this time is up you'll have getRateLimit() available again.
|
||||
*/
|
||||
public function getRateLimitReset() {
|
||||
return $this->_rateLimitReset;
|
||||
}
|
||||
|
||||
/**
|
||||
* The scope the user has
|
||||
*/
|
||||
public function getScope() {
|
||||
return $this->_scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function, parses out important information App.net adds
|
||||
* to the headers.
|
||||
*/
|
||||
protected function parseHeaders($response) {
|
||||
// take out the headers
|
||||
// set internal variables
|
||||
// return the body/content
|
||||
$this->_rateLimit = null;
|
||||
$this->_rateLimitRemaining = null;
|
||||
$this->_rateLimitReset = null;
|
||||
$this->_scope = null;
|
||||
|
||||
$response = explode("\r\n\r\n",$response,2);
|
||||
$headers = $response[0];
|
||||
|
||||
if($headers == 'HTTP/1.1 100 Continue') {
|
||||
$response = explode("\r\n\r\n",$response[1],2);
|
||||
$headers = $response[0];
|
||||
}
|
||||
|
||||
if (isset($response[1])) {
|
||||
$content = $response[1];
|
||||
}
|
||||
else {
|
||||
$content = null;
|
||||
}
|
||||
|
||||
// this is not a good way to parse http headers
|
||||
// it will not (for example) take into account multiline headers
|
||||
// but what we're looking for is pretty basic, so we can ignore those shortcomings
|
||||
$headers = explode("\r\n",$headers);
|
||||
foreach ($headers as $header) {
|
||||
$header = explode(': ',$header,2);
|
||||
if (count($header)<2) {
|
||||
continue;
|
||||
}
|
||||
list($k,$v) = $header;
|
||||
switch ($k) {
|
||||
case 'X-RateLimit-Remaining':
|
||||
$this->_rateLimitRemaining = $v;
|
||||
break;
|
||||
case 'X-RateLimit-Limit':
|
||||
$this->_rateLimit = $v;
|
||||
break;
|
||||
case 'X-RateLimit-Reset':
|
||||
$this->_rateLimitReset = $v;
|
||||
break;
|
||||
case 'X-OAuth-Scopes':
|
||||
$this->_scope = $v;
|
||||
$this->_scopes=explode(',',$v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function. Used to turn things like TRUE into 1, and then
|
||||
* calls http_build_query.
|
||||
*/
|
||||
protected function buildQueryString($array) {
|
||||
foreach ($array as $k=>&$v) {
|
||||
if ($v===true) {
|
||||
$v = '1';
|
||||
}
|
||||
elseif ($v===false) {
|
||||
$v = '0';
|
||||
}
|
||||
unset($v);
|
||||
}
|
||||
return http_build_query($array);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Internal function to handle all
|
||||
* HTTP requests (POST,PUT,GET,DELETE)
|
||||
*/
|
||||
protected function httpReq($act, $req, $params=array(),$contentType='application/x-www-form-urlencoded') {
|
||||
$ch = curl_init($req);
|
||||
$headers = array();
|
||||
if($act != 'get') {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
// if they passed an array, build a list of parameters from it
|
||||
if (is_array($params) && $act != 'post-raw') {
|
||||
$params = $this->buildQueryString($params);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
||||
$headers[] = "Content-Type: ".$contentType;
|
||||
}
|
||||
if($act != 'post' && $act != 'post-raw') {
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($act));
|
||||
}
|
||||
if($act == 'get' && isset($params['access_token'])) {
|
||||
$headers[] = 'Authorization: Bearer '.$params['access_token'];
|
||||
}
|
||||
else if ($this->_accessToken) {
|
||||
$headers[] = 'Authorization: Bearer '.$this->_accessToken;
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
if ($this->_sslCA) {
|
||||
curl_setopt($ch, CURLOPT_CAINFO, $this->_sslCA);
|
||||
}
|
||||
$this->_last_response = curl_exec($ch);
|
||||
$this->_last_request = curl_getinfo($ch,CURLINFO_HEADER_OUT);
|
||||
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($http_status==0) {
|
||||
throw new AppDotNetException('Unable to connect to '.$req);
|
||||
}
|
||||
if ($http_status<200 || $http_status>=300) {
|
||||
throw new AppDotNetException('HTTP error '.$this->_last_response);
|
||||
}
|
||||
if ($this->_last_request===false) {
|
||||
if (!curl_getinfo($ch,CURLINFO_SSL_VERIFYRESULT)) {
|
||||
throw new AppDotNetException('SSL verification failed, connection terminated.');
|
||||
}
|
||||
}
|
||||
$response = $this->parseHeaders($this->_last_response);
|
||||
$response = json_decode($response,true);
|
||||
|
||||
if (isset($response['meta'])) {
|
||||
if (isset($response['meta']['max_id'])) {
|
||||
$this->_maxid=$response['meta']['max_id'];
|
||||
$this->_minid=$response['meta']['min_id'];
|
||||
}
|
||||
if (isset($response['meta']['more'])) {
|
||||
$this->_more=$response['meta']['more'];
|
||||
}
|
||||
if (isset($response['meta']['marker'])) {
|
||||
$this->_last_marker=$response['meta']['marker'];
|
||||
}
|
||||
}
|
||||
|
||||
// look for errors
|
||||
if (isset($response['error'])) {
|
||||
if (is_array($response['error'])) {
|
||||
throw new AppDotNetException($response['error']['message'],
|
||||
$response['error']['code']);
|
||||
}
|
||||
else {
|
||||
throw new AppDotNetException($response['error']);
|
||||
}
|
||||
}
|
||||
|
||||
// look for response migration errors
|
||||
elseif (isset($response['meta']) && isset($response['meta']['error_message'])) {
|
||||
throw new AppDotNetException($response['meta']['error_message'],$response['meta']['code']);
|
||||
}
|
||||
|
||||
// if we've received a migration response, handle it and return data only
|
||||
elseif ($this->_stripResponseEnvelope && isset($response['meta']) && isset($response['data'])) {
|
||||
return $response['data'];
|
||||
}
|
||||
|
||||
// else non response migration response, just return it
|
||||
else {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get max_id from last meta response data envelope
|
||||
*/
|
||||
public function getResponseMaxID() {
|
||||
return $this->_maxid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get min_id from last meta response data envelope
|
||||
*/
|
||||
public function getResponseMinID() {
|
||||
return $this->_minid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get more from last meta response data envelope
|
||||
*/
|
||||
public function getResponseMore() {
|
||||
return $this->_more;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get marker from last meta response data envelope
|
||||
*/
|
||||
public function getResponseMarker() {
|
||||
return $this->_last_marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch API configuration object
|
||||
*/
|
||||
public function getConfig() {
|
||||
return $this->httpReq('get',$this->_baseUrl.'config');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Filters for the current user.
|
||||
*/
|
||||
public function getAllFilters() {
|
||||
return $this->httpReq('get',$this->_baseUrl.'filters');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Filter for the current user.
|
||||
* @param string $name The name of the new filter
|
||||
* @param array $filters An associative array of filters to be applied.
|
||||
* This may change as the API evolves, as of this writing possible
|
||||
* values are: user_ids, hashtags, link_domains, and mention_user_ids.
|
||||
* You will need to provide at least one filter name=>value pair.
|
||||
*/
|
||||
public function createFilter($name='New filter', $filters=array()) {
|
||||
$filters['name'] = $name;
|
||||
return $this->httpReq('post',$this->_baseUrl.'filters',$filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific Filter object.
|
||||
* @param integer $filter_id The ID of the filter you wish to retrieve.
|
||||
*/
|
||||
public function getFilter($filter_id=null) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'filters/'.urlencode($filter_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Filter. The Filter must belong to the current User.
|
||||
* @return object Returns the deleted Filter on success.
|
||||
*/
|
||||
public function deleteFilter($filter_id=null) {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'filters/'.urlencode($filter_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Process user description, message or post text.
|
||||
* Mentions and hashtags will be parsed out of the
|
||||
* text, as will bare URLs. To create a link in the text without using a
|
||||
* bare URL, include the anchor text in the object text and include a link
|
||||
* entity in the function call.
|
||||
* @param string $text The text of the description/message/post
|
||||
* @param array $data An associative array of optional post data. This
|
||||
* will likely change as the API evolves, as of this writing allowed keys are:
|
||||
* reply_to, and annotations. "annotations" may be a complex object represented
|
||||
* by an associative array.
|
||||
* @param array $params An associative array of optional data to be included
|
||||
* in the URL (such as 'include_annotations' and 'include_machine')
|
||||
* @return array An associative array representing the post.
|
||||
*/
|
||||
public function processText($text=null, $data = array(), $params = array()) {
|
||||
$data['text'] = $text;
|
||||
$json = json_encode($data);
|
||||
$qs = '';
|
||||
if (!empty($params)) {
|
||||
$qs = '?'.$this->buildQueryString($params);
|
||||
}
|
||||
return $this->httpReq('post',$this->_baseUrl.'text/process'.$qs, $json, 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Post object. Mentions and hashtags will be parsed out of the
|
||||
* post text, as will bare URLs. To create a link in a post without using a
|
||||
* bare URL, include the anchor text in the post's text and include a link
|
||||
* entity in the post creation call.
|
||||
* @param string $text The text of the post
|
||||
* @param array $data An associative array of optional post data. This
|
||||
* will likely change as the API evolves, as of this writing allowed keys are:
|
||||
* reply_to, and annotations. "annotations" may be a complex object represented
|
||||
* by an associative array.
|
||||
* @param array $params An associative array of optional data to be included
|
||||
* in the URL (such as 'include_annotations' and 'include_machine')
|
||||
* @return array An associative array representing the post.
|
||||
*/
|
||||
public function createPost($text=null, $data = array(), $params = array()) {
|
||||
$data['text'] = $text;
|
||||
|
||||
$json = json_encode($data);
|
||||
$qs = '';
|
||||
if (!empty($params)) {
|
||||
$qs = '?'.$this->buildQueryString($params);
|
||||
}
|
||||
return $this->httpReq('post',$this->_baseUrl.'posts'.$qs, $json, 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific Post.
|
||||
* @param integer $post_id The ID of the post to retrieve
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: include_annotations.
|
||||
* @return array An associative array representing the post
|
||||
*/
|
||||
public function getPost($post_id=null,$params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/'.urlencode($post_id)
|
||||
.'?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Post. The current user must be the same user who created the Post.
|
||||
* It returns the deleted Post on success.
|
||||
* @param integer $post_id The ID of the post to delete
|
||||
* @param array An associative array representing the post that was deleted
|
||||
*/
|
||||
public function deletePost($post_id=null) {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'posts/'.urlencode($post_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Posts that are 'in reply to' a specific Post.
|
||||
* @param integer $post_id The ID of the post you want to retrieve replies for.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||
* include_directed_posts, and include_annotations.
|
||||
* @return An array of associative arrays, each representing a single post.
|
||||
*/
|
||||
public function getPostReplies($post_id=null,$params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/'.urlencode($post_id)
|
||||
.'/replies?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recent Posts created by a specific User in reverse
|
||||
* chronological order (most recent first).
|
||||
* @param mixed $user_id Either the ID of the user you wish to retrieve posts by,
|
||||
* or the string "me", which will retrieve posts for the user you're authenticated
|
||||
* as.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||
* include_directed_posts, and include_annotations.
|
||||
* @return An array of associative arrays, each representing a single post.
|
||||
*/
|
||||
public function getUserPosts($user_id='me', $params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/'.urlencode($user_id)
|
||||
.'/posts?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recent Posts mentioning by a specific User in reverse
|
||||
* chronological order (newest first).
|
||||
* @param mixed $user_id Either the ID of the user who is being mentioned, or
|
||||
* the string "me", which will retrieve posts for the user you're authenticated
|
||||
* as.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||
* include_directed_posts, and include_annotations.
|
||||
* @return An array of associative arrays, each representing a single post.
|
||||
*/
|
||||
public function getUserMentions($user_id='me',$params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/'
|
||||
.urlencode($user_id).'/mentions?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the 20 most recent posts from the current User and
|
||||
* the Users they follow.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||
* include_directed_posts, and include_annotations.
|
||||
* @return An array of associative arrays, each representing a single post.
|
||||
*/
|
||||
public function getUserStream($params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/stream?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific user object.
|
||||
* @param mixed $user_id The ID of the user you want to retrieve, or the string
|
||||
* "me" to retrieve data for the users you're currently authenticated as.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: include_annotations|include_user_annotations.
|
||||
* @return array An associative array representing the user data.
|
||||
*/
|
||||
public function getUser($user_id='me', $params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/'.urlencode($user_id)
|
||||
.'?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns multiple users request by an array of user ids
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: include_annotations|include_user_annotations.
|
||||
* @return array An associative array representing the users data.
|
||||
*/
|
||||
public function getUsers($user_arr, $params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users?ids='.join(',',$user_arr)
|
||||
.'&'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified user ID to the list of users followed.
|
||||
* Returns the User object of the user being followed.
|
||||
* @param integer $user_id The user ID of the user to follow.
|
||||
* @return array An associative array representing the user you just followed.
|
||||
*/
|
||||
public function followUser($user_id=null) {
|
||||
return $this->httpReq('post',$this->_baseUrl.'users/'.urlencode($user_id).'/follow');
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified user ID to the list of users followed.
|
||||
* Returns the User object of the user being unfollowed.
|
||||
* @param integer $user_id The user ID of the user to unfollow.
|
||||
* @return array An associative array representing the user you just unfollowed.
|
||||
*/
|
||||
public function unfollowUser($user_id=null) {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'users/'.urlencode($user_id).'/follow');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of User objects the specified user is following.
|
||||
* @param mixed $user_id Either the ID of the user being followed, or
|
||||
* the string "me", which will retrieve posts for the user you're authenticated
|
||||
* as.
|
||||
* @return array An array of associative arrays, each representing a single
|
||||
* user following $user_id
|
||||
*/
|
||||
public function getFollowing($user_id='me') {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/'.$user_id.'/following');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of User objects for users following the specified user.
|
||||
* @param mixed $user_id Either the ID of the user being followed, or
|
||||
* the string "me", which will retrieve posts for the user you're authenticated
|
||||
* as.
|
||||
* @return array An array of associative arrays, each representing a single
|
||||
* user following $user_id
|
||||
*/
|
||||
public function getFollowers($user_id='me') {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/'.$user_id.'/followers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Posts matching a specific #hashtag.
|
||||
* @param string $hashtag The hashtag you're looking for.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||
* include_directed_posts, and include_annotations.
|
||||
* @return An array of associative arrays, each representing a single post.
|
||||
*/
|
||||
public function searchHashtags($hashtag=null, $params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/tag/'
|
||||
.urlencode($hashtag).'?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a list of all public Posts on App.net, often referred to as the
|
||||
* global stream.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||
* include_directed_posts, and include_annotations.
|
||||
* @return An array of associative arrays, each representing a single post.
|
||||
*/
|
||||
public function getPublicPosts($params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/stream/global?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* List User interactions
|
||||
*/
|
||||
public function getMyInteractions($params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/me/interactions?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user's user ID by specifying their username.
|
||||
* Now supported by the API. We use the API if we have a token
|
||||
* Otherwise we scrape the alpha.app.net site for the info.
|
||||
* @param string $username The username of the user you want the ID of, without
|
||||
* an @ symbol at the beginning.
|
||||
* @return integer The user's user ID
|
||||
*/
|
||||
public function getIdByUsername($username=null) {
|
||||
if ($this->_accessToken) {
|
||||
$res=$this->httpReq('get',$this->_baseUrl.'users/@'.$username);
|
||||
$user_id=$res['data']['id'];
|
||||
} else {
|
||||
$ch = curl_init('https://alpha.app.net/'.urlencode(strtolower($username)));
|
||||
curl_setopt($ch, CURLOPT_POST, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch,CURLOPT_USERAGENT,
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1');
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$temp = explode('title="User Id ',$response);
|
||||
$temp2 = explode('"',$temp[1]);
|
||||
$user_id = $temp2[0];
|
||||
}
|
||||
return $user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mute a user
|
||||
* @param integer $user_id The user ID to mute
|
||||
*/
|
||||
public function muteUser($user_id=null) {
|
||||
return $this->httpReq('post',$this->_baseUrl.'users/'.urlencode($user_id).'/mute');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmute a user
|
||||
* @param integer $user_id The user ID to unmute
|
||||
*/
|
||||
public function unmuteUser($user_id=null) {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'users/'.urlencode($user_id).'/mute');
|
||||
}
|
||||
|
||||
/**
|
||||
* List the users muted by the current user
|
||||
* @return array An array of associative arrays, each representing one muted user.
|
||||
*/
|
||||
public function getMuted() {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/me/muted');
|
||||
}
|
||||
|
||||
/**
|
||||
* Star a post
|
||||
* @param integer $post_id The post ID to star
|
||||
*/
|
||||
public function starPost($post_id=null) {
|
||||
return $this->httpReq('post',$this->_baseUrl.'posts/'.urlencode($post_id).'/star');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unstar a post
|
||||
* @param integer $post_id The post ID to unstar
|
||||
*/
|
||||
public function unstarPost($post_id=null) {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'posts/'.urlencode($post_id).'/star');
|
||||
}
|
||||
|
||||
/**
|
||||
* List the posts starred by the current user
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||
* include_directed_posts, and include_annotations.
|
||||
* See https://github.com/appdotnet/api-spec/blob/master/resources/posts.md#general-parameters
|
||||
* @return array An array of associative arrays, each representing a single
|
||||
* user who has starred a post
|
||||
*/
|
||||
public function getStarred($user_id='me', $params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/'.urlencode($user_id).'/stars'
|
||||
.'?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* List the users who have starred a post
|
||||
* @param integer $post_id the post ID to get stars from
|
||||
* @return array An array of associative arrays, each representing one user.
|
||||
*/
|
||||
public function getStars($post_id=null) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/'.urlencode($post_id).'/stars');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of User objects of users who reposted the specified post.
|
||||
* @param integer $post_id the post ID to
|
||||
* @return array An array of associative arrays, each representing a single
|
||||
* user who reposted $post_id
|
||||
*/
|
||||
public function getReposters($post_id){
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/'.urlencode($post_id).'/reposters');
|
||||
}
|
||||
|
||||
/**
|
||||
* Repost an existing Post object.
|
||||
* @param integer $post_id The id of the post
|
||||
* @return not a clue
|
||||
*/
|
||||
public function repost($post_id){
|
||||
return $this->httpReq('post',$this->_baseUrl.'posts/'.urlencode($post_id).'/repost');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a post that the user has reposted.
|
||||
* @param integer $post_id The id of the post
|
||||
* @return not a clue
|
||||
*/
|
||||
public function deleteRepost($post_id){
|
||||
return $this->httpReq('delete',$this->_baseUrl.'posts/'.urlencode($post_id).'/repost');
|
||||
}
|
||||
|
||||
/**
|
||||
* List the posts who match a specific search term
|
||||
* @param array $params a list of filter, search query, and general Post parameters
|
||||
* see: https://developers.app.net/reference/resources/post/search/
|
||||
* @param string $query The search query. Supports
|
||||
* normal search terms. Searches post text.
|
||||
* @return array An array of associative arrays, each representing one post.
|
||||
* or false on error
|
||||
*/
|
||||
public function searchPosts($params = array(), $query='', $order='default') {
|
||||
if (!is_array($params)) {
|
||||
return false;
|
||||
}
|
||||
if (!empty($query)) {
|
||||
$params['query']=$query;
|
||||
}
|
||||
if ($order=='default') {
|
||||
if (!empty($query)) {
|
||||
$params['order']='score';
|
||||
} else {
|
||||
$params['order']='id';
|
||||
}
|
||||
}
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/search?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List the users who match a specific search term
|
||||
* @param string $search The search query. Supports @username or #tag searches as
|
||||
* well as normal search terms. Searches username, display name, bio information.
|
||||
* Does not search posts.
|
||||
* @return array An array of associative arrays, each representing one user.
|
||||
*/
|
||||
public function searchUsers($search="") {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/search?q='.urlencode($search));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the 20 most recent posts for a stream using a valid Token
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||
* include_directed_posts, and include_annotations.
|
||||
* @return An array of associative arrays, each representing a single post.
|
||||
*/
|
||||
public function getTokenStream($params = array()) {
|
||||
if ($params['access_token']) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/stream?'.$this->buildQueryString($params),$params);
|
||||
} else {
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/stream?'.$this->buildQueryString($params));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user object by username
|
||||
* @param string $name the @name to get
|
||||
* @return array representing one user
|
||||
*/
|
||||
public function getUserByName($name=null) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/@'.$name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the 20 most recent Posts from the current User's personalized stream
|
||||
* and mentions stream merged into one stream.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||
* include_directed_posts, and include_annotations.
|
||||
* @return An array of associative arrays, each representing a single post.
|
||||
*/
|
||||
public function getUserUnifiedStream($params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'posts/stream/unified?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Profile Data via JSON
|
||||
* @data array containing user descriptors
|
||||
*/
|
||||
public function updateUserData($data = array(), $params = array()) {
|
||||
$json = json_encode($data);
|
||||
return $this->httpReq('put',$this->_baseUrl.'users/me'.'?'.
|
||||
$this->buildQueryString($params), $json, 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a user image
|
||||
* @which avatar|cover
|
||||
* @image path reference to image
|
||||
*/
|
||||
protected function updateUserImage($which = 'avatar', $image = null) {
|
||||
$data = array($which=>"@$image");
|
||||
return $this->httpReq('post-raw',$this->_baseUrl.'users/me/'.$which, $data, 'multipart/form-data');
|
||||
}
|
||||
|
||||
public function updateUserAvatar($avatar = null) {
|
||||
if($avatar != null)
|
||||
return $this->updateUserImage('avatar', $avatar);
|
||||
}
|
||||
|
||||
public function updateUserCover($cover = null) {
|
||||
if($cover != null)
|
||||
return $this->updateUserImage('cover', $cover);
|
||||
}
|
||||
|
||||
/**
|
||||
* update stream marker
|
||||
*/
|
||||
public function updateStreamMarker($data = array()) {
|
||||
$json = json_encode($data);
|
||||
return $this->httpReq('post',$this->_baseUrl.'posts/marker', $json, 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* get a page of current user subscribed channels
|
||||
*/
|
||||
public function getUserSubscriptions($params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'channels?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* get user channels
|
||||
*/
|
||||
public function getMyChannels($params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'channels/me?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* create a channel
|
||||
* note: you cannot create a channel with type=net.app.core.pm (see createMessage)
|
||||
*/
|
||||
public function createChannel($data = array()) {
|
||||
$json = json_encode($data);
|
||||
return $this->httpReq('post',$this->_baseUrl.'channels'.($pm?'/pm/messsages':''), $json, 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* get channelid info
|
||||
*/
|
||||
public function getChannel($channelid, $params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'channels/'.$channelid.'?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* get multiple channels' info by an array of channelids
|
||||
*/
|
||||
public function getChannels($channels, $params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'channels?ids='.join(',',$channels).'&'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* update channelid
|
||||
*/
|
||||
public function updateChannel($channelid, $data = array()) {
|
||||
$json = json_encode($data);
|
||||
return $this->httpReq('put',$this->_baseUrl.'channels/'.$channelid, $json, 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* subscribe from channelid
|
||||
*/
|
||||
public function channelSubscribe($channelid) {
|
||||
return $this->httpReq('post',$this->_baseUrl.'channels/'.$channelid.'/subscribe');
|
||||
}
|
||||
|
||||
/**
|
||||
* unsubscribe from channelid
|
||||
*/
|
||||
public function channelUnsubscribe($channelid) {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'channels/'.$channelid.'/subscribe');
|
||||
}
|
||||
|
||||
/**
|
||||
* get all user objects subscribed to channelid
|
||||
*/
|
||||
public function getChannelSubscriptions($channelid, $params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'channel/'.$channelid.'/subscribers?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* get all user IDs subscribed to channelid
|
||||
*/
|
||||
public function getChannelSubscriptionsById($channelid) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'channel/'.$channelid.'/subscribers/ids');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get a page of messages in channelid
|
||||
*/
|
||||
public function getMessages($channelid, $params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'channels/'.$channelid.'/messages?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* create message
|
||||
* @param $channelid numeric or "pm" for auto-chanenl (type=net.app.core.pm)
|
||||
* @param $data array('text'=>'YOUR_MESSAGE') If a type=net.app.core.pm, then "destinations" key can be set to address as an array of people to send this PM too
|
||||
*/
|
||||
public function createMessage($channelid,$data) {
|
||||
$json = json_encode($data);
|
||||
return $this->httpReq('post',$this->_baseUrl.'channels/'.$channelid.'/messages', $json, 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* get message
|
||||
*/
|
||||
public function getMessage($channelid,$messageid) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'channels/'.$channelid.'/messages/'.$messageid);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete messsage
|
||||
*/
|
||||
public function deleteMessage($channelid,$messageid) {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'channels/'.$channelid.'/messages/'.$messageid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Application Information
|
||||
*/
|
||||
public function getAppTokenInfo() {
|
||||
// requires appAccessToken
|
||||
if (!$this->_appAccessToken) {
|
||||
$this->getAppAccessToken();
|
||||
}
|
||||
// ensure request is made with our appAccessToken
|
||||
$params['access_token']=$this->_appAccessToken;
|
||||
return $this->httpReq('get',$this->_baseUrl.'token',$params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User Information
|
||||
*/
|
||||
public function getUserTokenInfo() {
|
||||
return $this->httpReq('get',$this->_baseUrl.'token');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Application Authorized User IDs
|
||||
*/
|
||||
public function getAppUserIDs() {
|
||||
// requires appAccessToken
|
||||
if (!$this->_appAccessToken) {
|
||||
$this->getAppAccessToken();
|
||||
}
|
||||
// ensure request is made with our appAccessToken
|
||||
$params['access_token']=$this->_appAccessToken;
|
||||
return $this->httpReq('get',$this->_baseUrl.'apps/me/tokens/user_ids',$params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Application Authorized User Tokens
|
||||
*/
|
||||
public function getAppUserTokens() {
|
||||
// requires appAccessToken
|
||||
if (!$this->_appAccessToken) {
|
||||
$this->getAppAccessToken();
|
||||
}
|
||||
// ensure request is made with our appAccessToken
|
||||
$params['access_token']=$this->_appAccessToken;
|
||||
return $this->httpReq('get',$this->_baseUrl.'apps/me/tokens',$params);
|
||||
}
|
||||
|
||||
public function getLastRequest() {
|
||||
return $this->_last_request;
|
||||
}
|
||||
public function getLastResponse() {
|
||||
return $this->_last_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers your function (or an array of object and method) to be called
|
||||
* whenever an event is received via an open app.net stream. Your function
|
||||
* will receive a single parameter, which is the object wrapper containing
|
||||
* the meta and data.
|
||||
* @param mixed A PHP callback (either a string containing the function name,
|
||||
* or an array where the first element is the class/object and the second
|
||||
* is the method).
|
||||
*/
|
||||
public function registerStreamFunction($function) {
|
||||
$this->_streamCallback = $function;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a stream that's been created for this user/app and starts sending
|
||||
* events/objects to your defined callback functions. You must define at
|
||||
* least one callback function before opening a stream.
|
||||
* @param mixed $stream Either a stream ID or the endpoint of a stream
|
||||
* you've already created. This stream must exist and must be valid for
|
||||
* your current access token. If you pass a stream ID, the library will
|
||||
* make an API call to get the endpoint.
|
||||
*
|
||||
* This function will return immediately, but your callback functions
|
||||
* will continue to receive events until you call closeStream() or until
|
||||
* App.net terminates the stream from their end with an error.
|
||||
*
|
||||
* If you're disconnected due to a network error, the library will
|
||||
* automatically attempt to reconnect you to the same stream, no action
|
||||
* on your part is necessary for this. However if the app.net API returns
|
||||
* an error, a reconnection attempt will not be made.
|
||||
*
|
||||
* Note there is no closeStream, because once you open a stream you
|
||||
* can't stop it (unless you exit() or die() or throw an uncaught
|
||||
* exception, or something else that terminates the script).
|
||||
* @return boolean True
|
||||
* @see createStream()
|
||||
*/
|
||||
public function openStream($stream) {
|
||||
// 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');
|
||||
}
|
||||
// must register a callback (or the exercise is pointless)
|
||||
if (!$this->_streamCallback) {
|
||||
throw new AppDotNetException('You must define your callback function using registerStreamFunction() before calling openStream');
|
||||
}
|
||||
// if the stream is a numeric value, get the stream info from the api
|
||||
if (is_numeric($stream)) {
|
||||
$stream = $this->getStream($stream);
|
||||
$this->_streamUrl = $stream['endpoint'];
|
||||
}
|
||||
else {
|
||||
$this->_streamUrl = $stream;
|
||||
}
|
||||
// continue doing this until we get an error back or something...?
|
||||
$this->httpStream('get',$this->_streamUrl);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the currently open stream.
|
||||
* @return true;
|
||||
*/
|
||||
public function closeStream() {
|
||||
if (!$this->_lastStreamActivity) {
|
||||
// never opened
|
||||
return;
|
||||
}
|
||||
if (!$this->_multiStream) {
|
||||
throw new AppDotNetException('You must open a stream before calling closeStream()');
|
||||
}
|
||||
curl_close($this->_currentStream);
|
||||
curl_multi_remove_handle($this->_multiStream,$this->_currentStream);
|
||||
curl_multi_close($this->_multiStream);
|
||||
$this->_currentStream = null;
|
||||
$this->_multiStream = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all streams for the current access token.
|
||||
* @return array An array of stream definitions.
|
||||
*/
|
||||
public function getAllStreams() {
|
||||
return $this->httpReq('get',$this->_baseUrl.'streams');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single stream specified by a stream ID. The stream must have been
|
||||
* created with the current access token.
|
||||
* @return array A stream definition
|
||||
*/
|
||||
public function getStream($streamId) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'streams/'.urlencode($streamId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a stream for the current app access token.
|
||||
*
|
||||
* @param array $objectTypes The objects you want to retrieve data for from the
|
||||
* stream. At time of writing these can be 'post', 'star', and/or 'user_follow'.
|
||||
* If you don't specify, all events will be retrieved.
|
||||
*/
|
||||
public function createStream($objectTypes=null) {
|
||||
// default object types to everything
|
||||
if (is_null($objectTypes)) {
|
||||
$objectTypes = array('post','star','user_follow');
|
||||
}
|
||||
$data = array(
|
||||
'object_types'=>$objectTypes,
|
||||
'type'=>'long_poll',
|
||||
);
|
||||
$data = json_encode($data);
|
||||
$response = $this->httpReq('post',$this->_baseUrl.'streams',$data,'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update stream for the current app access token
|
||||
*
|
||||
* @param integer $streamId The stream ID to update. This stream must have been
|
||||
* created by the current access token.
|
||||
* @param array $data allows object_types, type, filter_id and key to be updated. filter_id/key can be omitted
|
||||
*/
|
||||
public function updateStream($streamId,$data) {
|
||||
// objectTypes is likely required
|
||||
if (is_null($data['object_types'])) {
|
||||
$data['object_types'] = array('post','star','user_follow');
|
||||
}
|
||||
// type can still only be long_poll
|
||||
if (is_null($data['type'])) {
|
||||
$data['type']='long_poll';
|
||||
}
|
||||
$data = json_encode($data);
|
||||
$response = $this->httpReq('put',$this->_baseUrl.'streams/'.urlencode($streamId),$data,'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a stream if you no longer need it.
|
||||
*
|
||||
* @param integer $streamId The stream ID to delete. This stream must have been
|
||||
* created by the current access token.
|
||||
*/
|
||||
public function deleteStream($streamId) {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'streams/'.urlencode($streamId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all streams created by the current access token.
|
||||
*/
|
||||
public function deleteAllStreams() {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'streams');
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function used to process incoming chunks from the stream. This is only
|
||||
* public because it needs to be accessed by CURL. Do not call or use this function
|
||||
* in your own code.
|
||||
* @ignore
|
||||
*/
|
||||
public function httpStreamReceive($ch,$data) {
|
||||
$this->_lastStreamActivity = time();
|
||||
$this->_streamBuffer .= $data;
|
||||
if (!$this->_streamHeaders) {
|
||||
$pos = strpos($this->_streamBuffer,"\r\n\r\n");
|
||||
if ($pos!==false) {
|
||||
$this->_streamHeaders = substr($this->_streamBuffer,0,$pos);
|
||||
$this->_streamBuffer = substr($this->_streamBuffer,$pos+4);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$pos = strpos($this->_streamBuffer,"\r\n");
|
||||
while ($pos!==false) {
|
||||
$command = substr($this->_streamBuffer,0,$pos);
|
||||
$this->_streamBuffer = substr($this->_streamBuffer,$pos+2);
|
||||
$command = json_decode($command,true);
|
||||
if ($command) {
|
||||
call_user_func($this->_streamCallback,$command);
|
||||
}
|
||||
$pos = strpos($this->_streamBuffer,"\r\n");
|
||||
}
|
||||
}
|
||||
return strlen($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a long lived HTTP connection to the app.net servers, and sends data
|
||||
* received to the httpStreamReceive function. As a general rule you should not
|
||||
* directly call this method, it's used by openStream().
|
||||
*/
|
||||
protected function httpStream($act, $req, $params=array(),$contentType='application/x-www-form-urlencoded') {
|
||||
if ($this->_currentStream) {
|
||||
throw new AppDotNetException('There is already an open stream, you must close the existing one before opening a new one');
|
||||
}
|
||||
$headers = array();
|
||||
$this->_streamBuffer = '';
|
||||
if ($this->_accessToken) {
|
||||
$headers[] = 'Authorization: Bearer '.$this->_accessToken;
|
||||
}
|
||||
$this->_currentStream = curl_init($req);
|
||||
curl_setopt($this->_currentStream, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($this->_currentStream, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($this->_currentStream, CURLINFO_HEADER_OUT, true);
|
||||
curl_setopt($this->_currentStream, CURLOPT_HEADER, true);
|
||||
if ($this->_sslCA) {
|
||||
curl_setopt($this->_currentStream, CURLOPT_CAINFO, $this->_sslCA);
|
||||
}
|
||||
// every time we receive a chunk of data, forward it to httpStreamReceive
|
||||
curl_setopt($this->_currentStream, CURLOPT_WRITEFUNCTION, array($this, "httpStreamReceive"));
|
||||
|
||||
// curl_exec($ch);
|
||||
// return;
|
||||
|
||||
$this->_multiStream = curl_multi_init();
|
||||
$this->_lastStreamActivity = time();
|
||||
curl_multi_add_handle($this->_multiStream,$this->_currentStream);
|
||||
}
|
||||
|
||||
public function reconnectStream() {
|
||||
$this->closeStream();
|
||||
$this->_connectFailCounter++;
|
||||
// if we've failed a few times, back off
|
||||
if ($this->_connectFailCounter>1) {
|
||||
$sleepTime = pow(2,$this->_connectFailCounter);
|
||||
// don't sleep more than 60 seconds
|
||||
if ($sleepTime>60) {
|
||||
$sleepTime = 60;
|
||||
}
|
||||
sleep($sleepTime);
|
||||
}
|
||||
$this->httpStream('get',$this->_streamUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an open stream for x microseconds, then return. This is useful if you want
|
||||
* to be doing other things while processing the stream. If you just want to
|
||||
* consume the stream without other actions, you can call processForever() instead.
|
||||
* @param float @microseconds The number of microseconds to process for before
|
||||
* returning. There are 1,000,000 microseconds in a second.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function processStream($microseconds=null) {
|
||||
if (!$this->_multiStream) {
|
||||
throw new AppDotNetException('You must open a stream before calling processStream()');
|
||||
}
|
||||
$start = microtime(true);
|
||||
$active = null;
|
||||
$inQueue = null;
|
||||
$sleepFor = 0;
|
||||
do {
|
||||
// if we haven't received anything within 5.5 minutes, reconnect
|
||||
// keepalives are sent every 5 minutes (measured on 2013-3-12 by @ryantharp)
|
||||
if (time()-$this->_lastStreamActivity>=330) {
|
||||
$this->reconnectStream();
|
||||
}
|
||||
curl_multi_exec($this->_multiStream, $active);
|
||||
if (!$active) {
|
||||
$httpCode = curl_getinfo($this->_currentStream,CURLINFO_HTTP_CODE);
|
||||
// don't reconnect on 400 errors
|
||||
if ($httpCode>=400 && $httpCode<=499) {
|
||||
throw new AppDotNetException('Received HTTP error '.$httpCode.' check your URL and credentials before reconnecting');
|
||||
}
|
||||
$this->reconnectStream();
|
||||
}
|
||||
// sleep for a max of 2/10 of a second
|
||||
$timeSoFar = (microtime(true)-$start)*1000000;
|
||||
$sleepFor = $this->streamingSleepFor;
|
||||
if ($timeSoFar+$sleepFor>$microseconds) {
|
||||
$sleepFor = $microseconds - $timeSoFar;
|
||||
}
|
||||
|
||||
if ($sleepFor>0) {
|
||||
usleep($sleepFor);
|
||||
}
|
||||
} while ($timeSoFar+$sleepFor<$microseconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an open stream forever. This function will never return, if you
|
||||
* want to perform other actions while consuming the stream, you should use
|
||||
* processFor() instead.
|
||||
* @return void This function will never return
|
||||
* @see processFor();
|
||||
*/
|
||||
public function processStreamForever() {
|
||||
while (true) {
|
||||
$this->processStream(600);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Upload a file to a user's file store
|
||||
* @param string $file A string containing the path of the file to upload.
|
||||
* @param array $data Additional data about the file you're uploading. At the
|
||||
* moment accepted keys are: mime-type, kind, type, name, public and annotations.
|
||||
* - If you don't specify mime-type, ADNPHP will attempt to guess the mime type
|
||||
* based on the file, however this isn't always reliable.
|
||||
* - If you don't specify kind ADNPHP will attempt to determine if the file is
|
||||
* an image or not.
|
||||
* - If you don't specify name, ADNPHP will use the filename of the first
|
||||
* parameter.
|
||||
* - If you don't specify public, your file will be uploaded as a private file.
|
||||
* - Type is REQUIRED.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: include_annotations|include_file_annotations.
|
||||
* @return array An associative array representing the file
|
||||
*/
|
||||
public function createFile($file, $data, $params=array()) {
|
||||
if (!$file) {
|
||||
throw new AppDotNetException('You must specify a path to a file');
|
||||
}
|
||||
if (!file_exists($file)) {
|
||||
throw new AppDotNetException('File path specified does not exist');
|
||||
}
|
||||
if (!is_readable($file)) {
|
||||
throw new AppDotNetException('File path specified is not readable');
|
||||
}
|
||||
|
||||
if (!$data) {
|
||||
$data = array();
|
||||
}
|
||||
|
||||
if (!array_key_exists('type',$data) || !$data['type']) {
|
||||
throw new AppDotNetException('Type is required when creating a file');
|
||||
}
|
||||
|
||||
if (!array_key_exists('name',$data)) {
|
||||
$data['name'] = basename($file);
|
||||
}
|
||||
|
||||
if (array_key_exists('mime-type',$data)) {
|
||||
$mimeType = $data['mime-type'];
|
||||
unset($data['mime-type']);
|
||||
}
|
||||
else {
|
||||
$mimeType = null;
|
||||
}
|
||||
if (!array_key_exists('kind',$data)) {
|
||||
$test = @getimagesize($path);
|
||||
if ($test && array_key_exists('mime',$test)) {
|
||||
$data['kind'] = 'image';
|
||||
if (!$mimeType) {
|
||||
$mimeType = $test['mime'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data['kind'] = 'other';
|
||||
}
|
||||
}
|
||||
if (!$mimeType) {
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mimeType = finfo_file($finfo, $file);
|
||||
finfo_close($finfo);
|
||||
}
|
||||
if (!$mimeType) {
|
||||
throw new AppDotNetException('Unable to determine mime type of file, try specifying it explicitly');
|
||||
}
|
||||
if (!array_key_exists('public',$data) || !$data['public']) {
|
||||
$public = false;
|
||||
}
|
||||
else {
|
||||
$public = true;
|
||||
}
|
||||
|
||||
$data['content'] = "@$file;type=$mimeType";
|
||||
return $this->httpReq('post-raw',$this->_baseUrl.'files', $data, 'multipart/form-data');
|
||||
}
|
||||
|
||||
|
||||
public function createFilePlaceholder($file = null, $params=array()) {
|
||||
$name = basename($file);
|
||||
$data = array('annotations' => $params['annotations'], 'kind' => $params['kind'],
|
||||
'name' => $name, 'type' => $params['metadata']);
|
||||
$json = json_encode($data);
|
||||
return $this->httpReq('post',$this->_baseUrl.'files', $json, 'application/json');
|
||||
}
|
||||
|
||||
public function updateFileContent($fileid, $file) {
|
||||
|
||||
$data = file_get_contents($file);
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mime = finfo_file($finfo, $file);
|
||||
finfo_close($finfo);
|
||||
|
||||
return $this->httpReq('put',$this->_baseUrl.'files/' . $fileid
|
||||
.'/content', $data, $mime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows for file rename and annotation changes.
|
||||
* @param integer $file_id The ID of the file to update
|
||||
* @param array $params An associative array of file parameters.
|
||||
* @return array An associative array representing the updated file
|
||||
*/
|
||||
public function updateFile($file_id=null, $params=array()) {
|
||||
$data = array('annotations' => $params['annotations'] , 'name' => $params['name']);
|
||||
$json = json_encode($data);
|
||||
return $this->httpReq('put',$this->_baseUrl.'files/'.urlencode($file_id), $json, 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific File.
|
||||
* @param integer $file_id The ID of the file to retrieve
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: include_annotations|include_file_annotations.
|
||||
* @return array An associative array representing the file
|
||||
*/
|
||||
public function getFile($file_id=null,$params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'files/'.urlencode($file_id)
|
||||
.'?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
public function getFileContent($file_id=null,$params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'files/'.urlencode($file_id)
|
||||
.'/content?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/** $file_key : derived_file_key */
|
||||
public function getDerivedFileContent($file_id=null,$file_key=null,$params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'files/'.urlencode($file_id)
|
||||
.'/content/'.urlencode($file_key)
|
||||
.'?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns file objects.
|
||||
* @param array $file_ids The IDs of the files to retrieve
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: include_annotations|include_file_annotations.
|
||||
* @return array An associative array representing the file data.
|
||||
*/
|
||||
public function getFiles($file_ids=array(), $params = array()) {
|
||||
$ids = '';
|
||||
foreach($file_ids as $id) {
|
||||
$ids .= $id . ',';
|
||||
}
|
||||
$params['ids'] = substr($ids, 0, -1);
|
||||
return $this->httpReq('get',$this->_baseUrl.'files'
|
||||
.'?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a user's file objects.
|
||||
* @param array $params An associative array of optional general parameters.
|
||||
* This will likely change as the API evolves, as of this writing allowed keys
|
||||
* are: include_annotations|include_file_annotations|include_user_annotations.
|
||||
* @return array An associative array representing the file data.
|
||||
*/
|
||||
public function getUserFiles($params = array()) {
|
||||
return $this->httpReq('get',$this->_baseUrl.'users/me/files'
|
||||
.'?'.$this->buildQueryString($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a File. The current user must be the same user who created the File.
|
||||
* It returns the deleted File on success.
|
||||
* @param integer $file_id The ID of the file to delete
|
||||
* @return array An associative array representing the file that was deleted
|
||||
*/
|
||||
public function deleteFile($file_id=null) {
|
||||
return $this->httpReq('delete',$this->_baseUrl.'files/'.urlencode($file_id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AppDotNetException extends Exception {}
|
||||
23
appnet/DigiCertHighAssuranceEVRootCA.pem
Normal file
23
appnet/DigiCertHighAssuranceEVRootCA.pem
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs
|
||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||
d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
|
||||
ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL
|
||||
MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3
|
||||
LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug
|
||||
RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm
|
||||
+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW
|
||||
PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM
|
||||
xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB
|
||||
Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3
|
||||
hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg
|
||||
EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF
|
||||
MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA
|
||||
FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec
|
||||
nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z
|
||||
eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF
|
||||
hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2
|
||||
Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
|
||||
vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep
|
||||
+OkuE6N36B9K
|
||||
-----END CERTIFICATE-----
|
||||
15
appnet/README.md
Normal file
15
appnet/README.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
App.net Plugin
|
||||
==============
|
||||
|
||||
With this addon to friendica you can give your users the possibility to post their *public* messages to App.net and
|
||||
to import their timeline. The messages will be strapped their rich context and shortened to 256 characters length if
|
||||
necessary.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
If you have an developer account you can create an Application for all of your users at
|
||||
[https://account.app.net/developer/apps/](https://account.app.net/developer/apps/). Add the redirect uri
|
||||
"https://your.server.name/appnet/connect" (Replace "your.server.name" with the hostname of your server)
|
||||
|
||||
If you can't create an application (because you only have a free account) this addon still works, but your users have to create individual applications on their own.
|
||||
29
appnet/appnet.css
Executable file
29
appnet/appnet.css
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#appnet-import-label, #appnet-disconnect-label, #appnet-token-label,
|
||||
#appnet-enable-label, #appnet-bydefault-label,
|
||||
#appnet-clientid-label, #appnet-clientsecret-label {
|
||||
float: left;
|
||||
width: 200px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#appnet-import, #appnet-disconnect, #appnet-token,
|
||||
#appnet-checkbox, #appnet-bydefault,
|
||||
#appnet-clientid, #appnet-clientsecret {
|
||||
float: left;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#appnet-submit {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
#appnet-avatar {
|
||||
float: left;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
padding: 2px;
|
||||
}
|
||||
#appnet-info-block {
|
||||
height: 52px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
1358
appnet/appnet.php
Normal file
1358
appnet/appnet.php
Normal file
|
|
@ -0,0 +1,1358 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Name: App.net Connector
|
||||
* Description: Bidirectional (posting and reading) connector for app.net.
|
||||
* Version: 0.2
|
||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||
* Status: Unsupported
|
||||
*/
|
||||
|
||||
/*
|
||||
To-Do:
|
||||
- Use embedded pictures for the attachment information (large attachment)
|
||||
- Sound links must be handled
|
||||
- https://alpha.app.net/sr_rolando/post/32365203 - double pictures
|
||||
- https://alpha.app.net/opendev/post/34396399 - location data
|
||||
*/
|
||||
|
||||
require_once('include/enotify.php');
|
||||
require_once("include/socgraph.php");
|
||||
|
||||
define('APPNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||
|
||||
function appnet_install() {
|
||||
register_hook('post_local', 'addon/appnet/appnet.php', 'appnet_post_local');
|
||||
register_hook('notifier_normal', 'addon/appnet/appnet.php', 'appnet_send');
|
||||
register_hook('jot_networks', 'addon/appnet/appnet.php', 'appnet_jot_nets');
|
||||
register_hook('cron', 'addon/appnet/appnet.php', 'appnet_cron');
|
||||
register_hook('connector_settings', 'addon/appnet/appnet.php', 'appnet_settings');
|
||||
register_hook('connector_settings_post','addon/appnet/appnet.php', 'appnet_settings_post');
|
||||
register_hook('prepare_body', 'addon/appnet/appnet.php', 'appnet_prepare_body');
|
||||
register_hook('check_item_notification','addon/appnet/appnet.php', 'appnet_check_item_notification');
|
||||
}
|
||||
|
||||
|
||||
function appnet_uninstall() {
|
||||
unregister_hook('post_local', 'addon/appnet/appnet.php', 'appnet_post_local');
|
||||
unregister_hook('notifier_normal', 'addon/appnet/appnet.php', 'appnet_send');
|
||||
unregister_hook('jot_networks', 'addon/appnet/appnet.php', 'appnet_jot_nets');
|
||||
unregister_hook('cron', 'addon/appnet/appnet.php', 'appnet_cron');
|
||||
unregister_hook('connector_settings', 'addon/appnet/appnet.php', 'appnet_settings');
|
||||
unregister_hook('connector_settings_post', 'addon/appnet/appnet.php', 'appnet_settings_post');
|
||||
unregister_hook('prepare_body', 'addon/appnet/appnet.php', 'appnet_prepare_body');
|
||||
unregister_hook('check_item_notification','addon/appnet/appnet.php', 'appnet_check_item_notification');
|
||||
}
|
||||
|
||||
function appnet_module() {}
|
||||
|
||||
function appnet_content(&$a) {
|
||||
if(! local_user()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
return '';
|
||||
}
|
||||
|
||||
require_once("mod/settings.php");
|
||||
settings_init($a);
|
||||
|
||||
if (isset($a->argv[1]))
|
||||
switch ($a->argv[1]) {
|
||||
case "connect":
|
||||
$o = appnet_connect($a);
|
||||
break;
|
||||
default:
|
||||
$o = print_r($a->argv, true);
|
||||
break;
|
||||
}
|
||||
else
|
||||
$o = appnet_connect($a);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function appnet_check_item_notification($a, &$notification_data) {
|
||||
$own_id = get_pconfig($notification_data["uid"], 'appnet', 'ownid');
|
||||
|
||||
$own_user = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($notification_data["uid"]),
|
||||
dbesc("adn::".$own_id)
|
||||
);
|
||||
|
||||
if ($own_user)
|
||||
$notification_data["profiles"][] = $own_user[0]["url"];
|
||||
}
|
||||
|
||||
function appnet_plugin_admin(&$a, &$o){
|
||||
$t = get_markup_template( "admin.tpl", "addon/appnet/" );
|
||||
|
||||
$o = replace_macros($t, array(
|
||||
'$submit' => t('Save Settings'),
|
||||
// name, label, value, help, [extra values]
|
||||
'$clientid' => array('clientid', t('Client ID'), get_config('appnet', 'clientid' ), ''),
|
||||
'$clientsecret' => array('clientsecret', t('Client Secret'), get_config('appnet', 'clientsecret' ), ''),
|
||||
));
|
||||
}
|
||||
|
||||
function appnet_plugin_admin_post(&$a){
|
||||
$clientid = ((x($_POST,'clientid')) ? notags(trim($_POST['clientid'])) : '');
|
||||
$clientsecret = ((x($_POST,'clientsecret')) ? notags(trim($_POST['clientsecret'])): '');
|
||||
set_config('appnet','clientid',$clientid);
|
||||
set_config('appnet','clientsecret',$clientsecret);
|
||||
info( t('Settings updated.'). EOL );
|
||||
}
|
||||
|
||||
function appnet_connect(&$a) {
|
||||
require_once 'addon/appnet/AppDotNet.php';
|
||||
|
||||
$clientId = get_config('appnet','clientid');
|
||||
$clientSecret = get_config('appnet','clientsecret');
|
||||
|
||||
if (($clientId == "") || ($clientSecret == "")) {
|
||||
$clientId = get_pconfig(local_user(),'appnet','clientid');
|
||||
$clientSecret = get_pconfig(local_user(),'appnet','clientsecret');
|
||||
}
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
|
||||
try {
|
||||
$token = $app->getAccessToken($a->get_baseurl().'/appnet/connect');
|
||||
|
||||
logger("appnet_connect: authenticated");
|
||||
$o .= t("You are now authenticated to app.net. ");
|
||||
set_pconfig(local_user(),'appnet','token', $token);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
$o .= t("<p>Error fetching token. Please try again.</p>");
|
||||
}
|
||||
|
||||
$o .= '<br /><a href="'.$a->get_baseurl().'/settings/connectors">'.t("return to the connector page").'</a>';
|
||||
|
||||
return($o);
|
||||
}
|
||||
|
||||
function appnet_jot_nets(&$a,&$b) {
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
$post = get_pconfig(local_user(),'appnet','post');
|
||||
if(intval($post) == 1) {
|
||||
$defpost = get_pconfig(local_user(),'appnet','post_by_default');
|
||||
$selected = ((intval($defpost) == 1) ? ' checked="checked" ' : '');
|
||||
$b .= '<div class="profile-jot-net"><input type="checkbox" name="appnet_enable"' . $selected . ' value="1" /> '
|
||||
. t('Post to app.net') . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
function appnet_settings(&$a,&$s) {
|
||||
require_once 'addon/appnet/AppDotNet.php';
|
||||
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
$token = get_pconfig(local_user(),'appnet','token');
|
||||
|
||||
$app_clientId = get_config('appnet','clientid');
|
||||
$app_clientSecret = get_config('appnet','clientsecret');
|
||||
|
||||
if (($app_clientId == "") || ($app_clientSecret == "")) {
|
||||
$app_clientId = get_pconfig(local_user(),'appnet','clientid');
|
||||
$app_clientSecret = get_pconfig(local_user(),'appnet','clientsecret');
|
||||
}
|
||||
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/appnet/appnet.css' . '" media="all" />' . "\r\n";
|
||||
|
||||
$enabled = get_pconfig(local_user(),'appnet','post');
|
||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||
|
||||
$css = (($enabled) ? '' : '-disabled');
|
||||
|
||||
$def_enabled = get_pconfig(local_user(),'appnet','post_by_default');
|
||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
||||
|
||||
$importenabled = get_pconfig(local_user(),'appnet','import');
|
||||
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
||||
|
||||
$ownid = get_pconfig(local_user(),'appnet','ownid');
|
||||
|
||||
$s .= '<span id="settings_appnet_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_appnet_expanded\'); openClose(\'settings_appnet_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/appnet.png" /><h3 class="connector">'. t('App.net Import/Export').'</h3>';
|
||||
$s .= '</span>';
|
||||
$s .= '<div id="settings_appnet_expanded" class="settings-block" style="display: none;">';
|
||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_appnet_expanded\'); openClose(\'settings_appnet_inflated\');">';
|
||||
$s .= '<img class="connector'.$css.'" src="images/appnet.png" /><h3 class="connector">'. t('App.net Import/Export').'</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
if ($token != "") {
|
||||
$app = new AppDotNet($app_clientId, $app_clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
try {
|
||||
$userdata = $app->getUser();
|
||||
|
||||
if ($ownid != $userdata["id"])
|
||||
set_pconfig(local_user(),'appnet','ownid', $userdata["id"]);
|
||||
|
||||
$s .= '<div id="appnet-info" ><img id="appnet-avatar" src="'.$userdata["avatar_image"]["url"].'" /><p id="appnet-info-block">'. t('Currently connected to: ') .'<a href="'.$userdata["canonical_url"].'" target="_appnet">'.$userdata["username"].'</a><br /><em>'.$userdata["description"]["text"].'</em></p></div>';
|
||||
$s .= '<div id="appnet-enable-wrapper">';
|
||||
$s .= '<label id="appnet-enable-label" for="appnet-checkbox">' . t('Enable App.net Post Plugin') . '</label>';
|
||||
$s .= '<input id="appnet-checkbox" type="checkbox" name="appnet" value="1" ' . $checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="appnet-bydefault-wrapper">';
|
||||
$s .= '<label id="appnet-bydefault-label" for="appnet-bydefault">' . t('Post to App.net by default') . '</label>';
|
||||
$s .= '<input id="appnet-bydefault" type="checkbox" name="appnet_bydefault" value="1" ' . $def_checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<label id="appnet-import-label" for="appnet-import">'.t('Import the remote timeline').'</label>';
|
||||
$s .= '<input id="appnet-import" type="checkbox" name="appnet_import" value="1" '. $importchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
$s .= t("<p>Error fetching user profile. Please clear the configuration and try again.</p>");
|
||||
}
|
||||
|
||||
} elseif (($app_clientId == '') || ($app_clientSecret == '')) {
|
||||
$s .= t("<p>You have two ways to connect to App.net.</p>");
|
||||
$s .= "<hr />";
|
||||
$s .= t('<p>First way: Register an application at <a href="https://account.app.net/developer/apps/">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. ');
|
||||
$s .= sprintf(t("Use '%s' as Redirect URI<p>"), $a->get_baseurl().'/appnet/connect');
|
||||
$s .= '<div id="appnet-clientid-wrapper">';
|
||||
$s .= '<label id="appnet-clientid-label" for="appnet-clientid">' . t('Client ID') . '</label>';
|
||||
$s .= '<input id="appnet-clientid" type="text" name="clientid" value="" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= '<div id="appnet-clientsecret-wrapper">';
|
||||
$s .= '<label id="appnet-clientsecret-label" for="appnet-clientsecret">' . t('Client Secret') . '</label>';
|
||||
$s .= '<input id="appnet-clientsecret" type="text" name="clientsecret" value="" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$s .= "<hr />";
|
||||
$s .= t('<p>Second way: fetch a token at <a href="http://dev-lite.jonathonduerig.com/">http://dev-lite.jonathonduerig.com/</a>. ');
|
||||
$s .= t("Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>");
|
||||
$s .= '<div id="appnet-token-wrapper">';
|
||||
$s .= '<label id="appnet-token-label" for="appnet-token">' . t('Token') . '</label>';
|
||||
$s .= '<input id="appnet-token" type="text" name="token" value="'.$token.'" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
} else {
|
||||
$app = new AppDotNet($app_clientId, $app_clientSecret);
|
||||
|
||||
$scope = array('basic', 'stream', 'write_post',
|
||||
'public_messages', 'messages');
|
||||
|
||||
$url = $app->getAuthUrl($a->get_baseurl().'/appnet/connect', $scope);
|
||||
$s .= '<div class="clear"></div>';
|
||||
$s .= '<a href="'.$url.'">'.t("Sign in using App.net").'</a>';
|
||||
}
|
||||
|
||||
if (($app_clientId != '') || ($app_clientSecret != '') || ($token !='')) {
|
||||
$s .= '<div id="appnet-disconnect-wrapper">';
|
||||
$s .= '<label id="appnet-disconnect-label" for="appnet-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
||||
|
||||
$s .= '<input id="appnet-disconnect" type="checkbox" name="appnet-disconnect" value="1" />';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
}
|
||||
|
||||
/* provide a submit button */
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="appnet-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
|
||||
|
||||
$s .= '</div>';
|
||||
}
|
||||
|
||||
function appnet_settings_post(&$a,&$b) {
|
||||
|
||||
if(x($_POST,'appnet-submit')) {
|
||||
|
||||
if (isset($_POST['appnet-disconnect'])) {
|
||||
del_pconfig(local_user(), 'appnet', 'clientsecret');
|
||||
del_pconfig(local_user(), 'appnet', 'clientid');
|
||||
del_pconfig(local_user(), 'appnet', 'token');
|
||||
del_pconfig(local_user(), 'appnet', 'post');
|
||||
del_pconfig(local_user(), 'appnet', 'post_by_default');
|
||||
del_pconfig(local_user(), 'appnet', 'import');
|
||||
}
|
||||
|
||||
if (isset($_POST["clientsecret"]))
|
||||
set_pconfig(local_user(),'appnet','clientsecret', $_POST['clientsecret']);
|
||||
|
||||
if (isset($_POST["clientid"]))
|
||||
set_pconfig(local_user(),'appnet','clientid', $_POST['clientid']);
|
||||
|
||||
if (isset($_POST["token"]) && ($_POST["token"] != ""))
|
||||
set_pconfig(local_user(),'appnet','token', $_POST['token']);
|
||||
|
||||
set_pconfig(local_user(), 'appnet', 'post', intval($_POST['appnet']));
|
||||
set_pconfig(local_user(), 'appnet', 'post_by_default', intval($_POST['appnet_bydefault']));
|
||||
set_pconfig(local_user(), 'appnet', 'import', intval($_POST['appnet_import']));
|
||||
}
|
||||
}
|
||||
|
||||
function appnet_post_local(&$a,&$b) {
|
||||
if($b['edit'])
|
||||
return;
|
||||
|
||||
if((local_user()) && (local_user() == $b['uid']) && (!$b['private']) && (!$b['parent'])) {
|
||||
$appnet_post = intval(get_pconfig(local_user(),'appnet','post'));
|
||||
$appnet_enable = (($appnet_post && x($_REQUEST,'appnet_enable')) ? intval($_REQUEST['appnet_enable']) : 0);
|
||||
|
||||
// if API is used, default to the chosen settings
|
||||
if($b['api_source'] && intval(get_pconfig(local_user(),'appnet','post_by_default')))
|
||||
$appnet_enable = 1;
|
||||
|
||||
if(! $appnet_enable)
|
||||
return;
|
||||
|
||||
if(strlen($b['postopts']))
|
||||
$b['postopts'] .= ',';
|
||||
|
||||
$b['postopts'] .= 'appnet';
|
||||
}
|
||||
}
|
||||
|
||||
function appnet_create_entities($a, $b, $postdata) {
|
||||
require_once("include/bbcode.php");
|
||||
require_once("include/plaintext.php");
|
||||
|
||||
$bbcode = $b["body"];
|
||||
$bbcode = bb_remove_share_information($bbcode, false, true);
|
||||
|
||||
// Change pure links in text to bbcode uris
|
||||
$bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
|
||||
|
||||
$URLSearchString = "^\[\]";
|
||||
|
||||
$bbcode = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'#$2',$bbcode);
|
||||
$bbcode = preg_replace("/@\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'@$2',$bbcode);
|
||||
$bbcode = preg_replace("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$bbcode);
|
||||
$bbcode = preg_replace("/\[video\](.*?)\[\/video\]/ism",'[url=$1]$1[/url]',$bbcode);
|
||||
$bbcode = preg_replace("/\[youtube\]https?:\/\/(.*?)\[\/youtube\]/ism",'[url=https://$1]https://$1[/url]',$bbcode);
|
||||
$bbcode = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
|
||||
'[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode);
|
||||
$bbcode = preg_replace("/\[vimeo\]https?:\/\/(.*?)\[\/vimeo\]/ism",'[url=https://$1]https://$1[/url]',$bbcode);
|
||||
$bbcode = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
|
||||
'[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode);
|
||||
//$bbcode = preg_replace("/\[vimeo\](.*?)\[\/vimeo\]/ism",'[url=$1]$1[/url]',$bbcode);
|
||||
|
||||
$bbcode = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $bbcode);
|
||||
|
||||
|
||||
preg_match_all("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $bbcode, $urls, PREG_SET_ORDER);
|
||||
|
||||
$bbcode = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'$1',$bbcode);
|
||||
|
||||
$b["body"] = $bbcode;
|
||||
|
||||
// To-Do:
|
||||
// Bilder
|
||||
// https://alpha.app.net/heluecht/post/32424376
|
||||
// https://alpha.app.net/heluecht/post/32424307
|
||||
|
||||
$plaintext = plaintext($a, $b, 0, false, 6);
|
||||
|
||||
$text = $plaintext["text"];
|
||||
|
||||
$start = 0;
|
||||
$entities = array();
|
||||
|
||||
foreach ($urls AS $url) {
|
||||
$lenurl = iconv_strlen($url[1], "UTF-8");
|
||||
$len = iconv_strlen($url[2], "UTF-8");
|
||||
$pos = iconv_strpos($text, $url[1], $start, "UTF-8");
|
||||
$pre = iconv_substr($text, 0, $pos, "UTF-8");
|
||||
$post = iconv_substr($text, $pos + $lenurl, 1000000, "UTF-8");
|
||||
|
||||
$mid = $url[2];
|
||||
$html = bbcode($mid, false, false, 6);
|
||||
$mid = html2plain($html, 0, true);
|
||||
|
||||
$mid = trim(html_entity_decode($mid,ENT_QUOTES,'UTF-8'));
|
||||
|
||||
$text = $pre.$mid.$post;
|
||||
|
||||
if ($mid != "")
|
||||
$entities[] = array("pos" => $pos, "len" => $len, "url" => $url[1], "text" => $mid);
|
||||
|
||||
$start = $pos + 1;
|
||||
}
|
||||
|
||||
if (isset($postdata["url"]) && isset($postdata["title"]) && ($postdata["type"] != "photo")) {
|
||||
$postdata["title"] = shortenmsg($postdata["title"], 90);
|
||||
$max = 256 - strlen($postdata["title"]);
|
||||
$text = shortenmsg($text, $max);
|
||||
$text .= "\n[".$postdata["title"]."](".$postdata["url"].")";
|
||||
} elseif (isset($postdata["url"]) && ($postdata["type"] != "photo")) {
|
||||
$postdata["url"] = short_link($postdata["url"]);
|
||||
$max = 240;
|
||||
$text = shortenmsg($text, $max);
|
||||
$text .= " [".$postdata["url"]."](".$postdata["url"].")";
|
||||
} else {
|
||||
$max = 256;
|
||||
$text = shortenmsg($text, $max);
|
||||
}
|
||||
|
||||
if (iconv_strlen($text, "UTF-8") < $max)
|
||||
$max = iconv_strlen($text, "UTF-8");
|
||||
|
||||
krsort($entities);
|
||||
foreach ($entities AS $entity) {
|
||||
//if (iconv_strlen($text, "UTF-8") >= $entity["pos"] + $entity["len"]) {
|
||||
if (($entity["pos"] + $entity["len"]) <= $max) {
|
||||
$pre = iconv_substr($text, 0, $entity["pos"], "UTF-8");
|
||||
$post = iconv_substr($text, $entity["pos"] + $entity["len"], 1000000, "UTF-8");
|
||||
|
||||
$text = $pre."[".$entity["text"]."](".$entity["url"].")".$post;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return($text);
|
||||
}
|
||||
|
||||
function appnet_send(&$a,&$b) {
|
||||
|
||||
logger('appnet_send: invoked for post '.$b['id']." ".$b['app']);
|
||||
|
||||
if (!get_pconfig($b["uid"],'appnet','import')) {
|
||||
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
|
||||
return;
|
||||
}
|
||||
|
||||
if($b['parent'] != $b['id']) {
|
||||
logger("appnet_send: parameter ".print_r($b, true), LOGGER_DATA);
|
||||
|
||||
// Looking if its a reply to an app.net post
|
||||
if ((substr($b["parent-uri"], 0, 5) != "adn::") && (substr($b["extid"], 0, 5) != "adn::") && (substr($b["thr-parent"], 0, 5) != "adn::")) {
|
||||
logger("appnet_send: no app.net post ".$b["parent"]);
|
||||
return;
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
|
||||
dbesc($b["thr-parent"]),
|
||||
intval($b["uid"]));
|
||||
|
||||
if(!count($r)) {
|
||||
logger("appnet_send: no parent found ".$b["thr-parent"]);
|
||||
return;
|
||||
} else {
|
||||
$iscomment = true;
|
||||
$orig_post = $r[0];
|
||||
}
|
||||
|
||||
$nicknameplain = preg_replace("=https?://alpha.app.net/(.*)=ism", "$1", $orig_post["author-link"]);
|
||||
$nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
|
||||
$nicknameplain = "@".$nicknameplain;
|
||||
|
||||
logger("appnet_send: comparing ".$nickname." and ".$nicknameplain." with ".$b["body"], LOGGER_DEBUG);
|
||||
if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false))
|
||||
$b["body"] = $nickname." ".$b["body"];
|
||||
|
||||
logger("appnet_send: parent found ".print_r($orig_post, true), LOGGER_DATA);
|
||||
} else {
|
||||
$iscomment = false;
|
||||
|
||||
if($b['private'] || !strstr($b['postopts'],'appnet'))
|
||||
return;
|
||||
}
|
||||
|
||||
if (($b['verb'] == ACTIVITY_POST) && $b['deleted'])
|
||||
appnet_action($a, $b["uid"], substr($orig_post["uri"], 5), "delete");
|
||||
|
||||
if($b['verb'] == ACTIVITY_LIKE) {
|
||||
logger("appnet_send: ".print_r($b, true), LOGGER_DEBUG);
|
||||
logger("appnet_send: parameter 2 ".substr($b["thr-parent"], 5), LOGGER_DEBUG);
|
||||
if ($b['deleted'])
|
||||
appnet_action($a, $b["uid"], substr($b["thr-parent"], 5), "unlike");
|
||||
else
|
||||
appnet_action($a, $b["uid"], substr($b["thr-parent"], 5), "like");
|
||||
return;
|
||||
}
|
||||
|
||||
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
||||
return;
|
||||
|
||||
$token = get_pconfig($b['uid'],'appnet','token');
|
||||
|
||||
if($token) {
|
||||
|
||||
// If it's a repeated message from app.net then do a native repost and exit
|
||||
if (appnet_is_repost($a, $b['uid'], $b['body']))
|
||||
return;
|
||||
|
||||
|
||||
require_once 'addon/appnet/AppDotNet.php';
|
||||
|
||||
$clientId = get_pconfig($b["uid"],'appnet','clientid');
|
||||
$clientSecret = get_pconfig($b["uid"],'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
$data = array();
|
||||
|
||||
require_once("include/plaintext.php");
|
||||
require_once("include/network.php");
|
||||
|
||||
$post = plaintext($a, $b, 256, false, 6);
|
||||
logger("appnet_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG);
|
||||
|
||||
if (isset($post["image"])) {
|
||||
$img_str = fetch_url($post['image'],true, $redirects, 10);
|
||||
$tempfile = tempnam(get_temppath(), "cache");
|
||||
file_put_contents($tempfile, $img_str);
|
||||
|
||||
try {
|
||||
$photoFile = $app->createFile($tempfile, array(type => "com.github.jdolitsky.appdotnetphp.photo"));
|
||||
|
||||
$data["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")
|
||||
)
|
||||
);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger("appnet_send: Error creating file ".appnet_error($e->getMessage()));
|
||||
}
|
||||
|
||||
unlink($tempfile);
|
||||
}
|
||||
|
||||
// Adding a link to the original post, if it is a root post
|
||||
if($b['parent'] == $b['id'])
|
||||
$data["annotations"][] = array(
|
||||
"type" => "net.app.core.crosspost",
|
||||
"value" => array("canonical_url" => $b["plink"])
|
||||
);
|
||||
|
||||
// Adding the original post
|
||||
$attached_data = get_attached_data($b["body"]);
|
||||
$attached_data["post-uri"] = $b["uri"];
|
||||
$attached_data["post-title"] = $b["title"];
|
||||
$attached_data["post-body"] = substr($b["body"], 0, 4000); // To-Do: Better shortening
|
||||
$attached_data["post-tag"] = $b["tag"];
|
||||
$attached_data["author-name"] = $b["author-name"];
|
||||
$attached_data["author-link"] = $b["author-link"];
|
||||
$attached_data["author-avatar"] = $b["author-avatar"];
|
||||
|
||||
$data["annotations"][] = array(
|
||||
"type" => "com.friendica.post",
|
||||
"value" => $attached_data
|
||||
);
|
||||
|
||||
if (isset($post["url"]) && !isset($post["title"]) && ($post["type"] != "photo")) {
|
||||
$display_url = str_replace(array("http://www.", "https://www."), array("", ""), $post["url"]);
|
||||
$display_url = str_replace(array("http://", "https://"), array("", ""), $display_url);
|
||||
|
||||
if (strlen($display_url) > 26)
|
||||
$display_url = substr($display_url, 0, 25)."…";
|
||||
|
||||
$post["title"] = $display_url;
|
||||
}
|
||||
|
||||
$text = appnet_create_entities($a, $b, $post);
|
||||
|
||||
$data["entities"]["parse_markdown_links"] = true;
|
||||
|
||||
if ($iscomment)
|
||||
$data["reply_to"] = substr($orig_post["uri"], 5);
|
||||
|
||||
try {
|
||||
logger("appnet_send: sending message ".$b["id"]." ".$text." ".print_r($data, true), LOGGER_DEBUG);
|
||||
$ret = $app->createPost($text, $data);
|
||||
logger("appnet_send: send message ".$b["id"]." result: ".print_r($ret, true), LOGGER_DEBUG);
|
||||
if ($iscomment) {
|
||||
logger('appnet_send: Update extid '.$ret["id"]." for post id ".$b['id']);
|
||||
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
|
||||
dbesc("adn::".$ret["id"]),
|
||||
intval($b['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger("appnet_send: Error sending message ".$b["id"]." ".appnet_error($e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function appnet_action($a, $uid, $pid, $action) {
|
||||
require_once 'addon/appnet/AppDotNet.php';
|
||||
|
||||
$token = get_pconfig($uid,'appnet','token');
|
||||
$clientId = get_pconfig($uid,'appnet','clientid');
|
||||
$clientSecret = get_pconfig($uid,'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
logger("appnet_action '".$action."' ID: ".$pid, LOGGER_DATA);
|
||||
|
||||
try {
|
||||
switch ($action) {
|
||||
case "delete":
|
||||
$result = $app->deletePost($pid);
|
||||
break;
|
||||
case "like":
|
||||
$result = $app->starPost($pid);
|
||||
break;
|
||||
case "unlike":
|
||||
$result = $app->unstarPost($pid);
|
||||
break;
|
||||
}
|
||||
logger("appnet_action '".$action."' send, result: " . print_r($result, true), LOGGER_DEBUG);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger("appnet_action: Error sending action ".$action." pid ".$pid." ".appnet_error($e->getMessage()), LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
function appnet_is_repost($a, $uid, $body) {
|
||||
$body = trim($body);
|
||||
|
||||
// Skip if it isn't a pure repeated messages
|
||||
// Does it start with a share?
|
||||
if (strpos($body, "[share") > 0)
|
||||
return(false);
|
||||
|
||||
// Does it end with a share?
|
||||
if (strlen($body) > (strrpos($body, "[/share]") + 8))
|
||||
return(false);
|
||||
|
||||
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
|
||||
// Skip if there is no shared message in there
|
||||
if ($body == $attributes)
|
||||
return(false);
|
||||
|
||||
$link = "";
|
||||
preg_match("/link='(.*?)'/ism", $attributes, $matches);
|
||||
if ($matches[1] != "")
|
||||
$link = $matches[1];
|
||||
|
||||
preg_match('/link="(.*?)"/ism', $attributes, $matches);
|
||||
if ($matches[1] != "")
|
||||
$link = $matches[1];
|
||||
|
||||
$id = preg_replace("=https?://alpha.app.net/(.*)/post/(.*)=ism", "$2", $link);
|
||||
if ($id == $link)
|
||||
return(false);
|
||||
|
||||
logger('appnet_is_repost: Reposting id '.$id.' for user '.$uid, LOGGER_DEBUG);
|
||||
|
||||
require_once 'addon/appnet/AppDotNet.php';
|
||||
|
||||
$token = get_pconfig($uid,'appnet','token');
|
||||
$clientId = get_pconfig($uid,'appnet','clientid');
|
||||
$clientSecret = get_pconfig($uid,'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
try {
|
||||
$result = $app->repost($id);
|
||||
logger('appnet_is_repost: result '.print_r($result, true), LOGGER_DEBUG);
|
||||
return true;
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger('appnet_is_repost: error doing repost '.appnet_error($e->getMessage()), LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function appnet_fetchstream($a, $uid) {
|
||||
require_once("addon/appnet/AppDotNet.php");
|
||||
require_once('include/items.php');
|
||||
|
||||
$token = get_pconfig($uid,'appnet','token');
|
||||
$clientId = get_pconfig($uid,'appnet','clientid');
|
||||
$clientSecret = get_pconfig($uid,'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if(count($r))
|
||||
$me = $r[0];
|
||||
else {
|
||||
logger("appnet_fetchstream: Own contact not found for user ".$uid, LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
$user = q("SELECT * FROM `user` WHERE `uid` = %d AND `account_expired` = 0 LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if(count($user))
|
||||
$user = $user[0];
|
||||
else {
|
||||
logger("appnet_fetchstream: Own user not found for user ".$uid, LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
$ownid = get_pconfig($uid,'appnet','ownid');
|
||||
|
||||
// Fetch stream
|
||||
$param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true,
|
||||
"include_html" => false, "include_post_annotations" => true);
|
||||
|
||||
$lastid = get_pconfig($uid, 'appnet', 'laststreamid');
|
||||
|
||||
if ($lastid <> "")
|
||||
$param["since_id"] = $lastid;
|
||||
|
||||
try {
|
||||
$stream = $app->getUserStream($param);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger("appnet_fetchstream: Error fetching stream for user ".$uid." ".appnet_error($e->getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_array($stream))
|
||||
$stream = array();
|
||||
|
||||
$stream = array_reverse($stream);
|
||||
foreach ($stream AS $post) {
|
||||
$postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, true);
|
||||
|
||||
$item = item_store($postarray);
|
||||
$postarray["id"] = $item;
|
||||
|
||||
logger('appnet_fetchstream: User '.$uid.' posted stream item '.$item);
|
||||
|
||||
$lastid = $post["id"];
|
||||
|
||||
if (($item != 0) && ($postarray['contact-id'] != $me["id"]) && !function_exists("check_item_notification")) {
|
||||
$r = q("SELECT `thread`.`iid` AS `parent` FROM `thread`
|
||||
INNER JOIN `item` ON `thread`.`iid` = `item`.`parent` AND `thread`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`id` = %d AND `thread`.`mention` LIMIT 1", dbesc($item));
|
||||
|
||||
if (count($r)) {
|
||||
require_once('include/enotify.php');
|
||||
notification(array(
|
||||
'type' => NOTIFY_COMMENT,
|
||||
'notify_flags' => $user['notify-flags'],
|
||||
'language' => $user['language'],
|
||||
'to_name' => $user['username'],
|
||||
'to_email' => $user['email'],
|
||||
'uid' => $user['uid'],
|
||||
'item' => $postarray,
|
||||
'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
|
||||
'source_name' => $postarray['author-name'],
|
||||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_POST,
|
||||
'otype' => 'item',
|
||||
'parent' => $r[0]["parent"],
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set_pconfig($uid, 'appnet', 'laststreamid', $lastid);
|
||||
|
||||
// Fetch mentions
|
||||
$param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true,
|
||||
"include_html" => false, "include_post_annotations" => true);
|
||||
|
||||
$lastid = get_pconfig($uid, 'appnet', 'lastmentionid');
|
||||
|
||||
if ($lastid <> "")
|
||||
$param["since_id"] = $lastid;
|
||||
|
||||
try {
|
||||
$mentions = $app->getUserMentions("me", $param);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger("appnet_fetchstream: Error fetching mentions for user ".$uid." ".appnet_error($e->getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_array($mentions))
|
||||
$mentions = array();
|
||||
|
||||
$mentions = array_reverse($mentions);
|
||||
foreach ($mentions AS $post) {
|
||||
$postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, false);
|
||||
|
||||
if (isset($postarray["id"])) {
|
||||
$item = $postarray["id"];
|
||||
$parent_id = $postarray['parent'];
|
||||
} elseif (isset($postarray["body"])) {
|
||||
$item = item_store($postarray);
|
||||
$postarray["id"] = $item;
|
||||
|
||||
$parent_id = 0;
|
||||
logger('appnet_fetchstream: User '.$uid.' posted mention item '.$item);
|
||||
|
||||
if ($item && function_exists("check_item_notification"))
|
||||
check_item_notification($item, $uid, NOTIFY_TAGSELF);
|
||||
|
||||
} else {
|
||||
$item = 0;
|
||||
$parent_id = 0;
|
||||
}
|
||||
|
||||
// Fetch the parent and id
|
||||
if (($parent_id == 0) && ($postarray['uri'] != "")) {
|
||||
$r = q("SELECT `id`, `parent` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if (count($r)) {
|
||||
$item = $r[0]['id'];
|
||||
$parent_id = $r[0]['parent'];
|
||||
}
|
||||
}
|
||||
|
||||
$lastid = $post["id"];
|
||||
|
||||
//if (($item != 0) && ($postarray['contact-id'] != $me["id"])) {
|
||||
if (($item != 0) && !function_exists("check_item_notification")) {
|
||||
require_once('include/enotify.php');
|
||||
notification(array(
|
||||
'type' => NOTIFY_TAGSELF,
|
||||
'notify_flags' => $user['notify-flags'],
|
||||
'language' => $user['language'],
|
||||
'to_name' => $user['username'],
|
||||
'to_email' => $user['email'],
|
||||
'uid' => $user['uid'],
|
||||
'item' => $postarray,
|
||||
'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
|
||||
'source_name' => $postarray['author-name'],
|
||||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_TAG,
|
||||
'otype' => 'item',
|
||||
'parent' => $parent_id,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
set_pconfig($uid, 'appnet', 'lastmentionid', $lastid);
|
||||
|
||||
|
||||
/* To-Do
|
||||
$param = array("interaction_actions" => "star");
|
||||
$interactions = $app->getMyInteractions($param);
|
||||
foreach ($interactions AS $interaction)
|
||||
appnet_dolike($a, $uid, $interaction);
|
||||
*/
|
||||
}
|
||||
|
||||
function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $threadcompletion = true, $nodupcheck = false) {
|
||||
require_once('include/items.php');
|
||||
|
||||
if ($post["machine_only"])
|
||||
return;
|
||||
|
||||
if ($post["is_deleted"])
|
||||
return;
|
||||
|
||||
$postarray = array();
|
||||
$postarray['gravity'] = 0;
|
||||
$postarray['uid'] = $uid;
|
||||
$postarray['wall'] = 0;
|
||||
$postarray['verb'] = ACTIVITY_POST;
|
||||
$postarray['network'] = dbesc(NETWORK_APPNET);
|
||||
if (is_array($post["repost_of"])) {
|
||||
// You can't reply to reposts. So use the original id and thread-id
|
||||
$postarray['uri'] = "adn::".$post["repost_of"]["id"];
|
||||
$postarray['parent-uri'] = "adn::".$post["repost_of"]["thread_id"];
|
||||
} else {
|
||||
$postarray['uri'] = "adn::".$post["id"];
|
||||
$postarray['parent-uri'] = "adn::".$post["thread_id"];
|
||||
}
|
||||
|
||||
if (!$nodupcheck) {
|
||||
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if (count($r))
|
||||
return($r[0]);
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if (count($r))
|
||||
return($r[0]);
|
||||
}
|
||||
|
||||
if (isset($post["reply_to"]) && ($post["reply_to"] != "")) {
|
||||
$postarray['thr-parent'] = "adn::".$post["reply_to"];
|
||||
|
||||
// Complete the thread (if the parent doesn't exists)
|
||||
if ($threadcompletion) {
|
||||
//$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
// dbesc($postarray['thr-parent']),
|
||||
// intval($uid)
|
||||
// );
|
||||
//if (!count($r)) {
|
||||
logger("appnet_createpost: completing thread ".$post["thread_id"]." for user ".$uid, LOGGER_DEBUG);
|
||||
|
||||
require_once("addon/appnet/AppDotNet.php");
|
||||
|
||||
$token = get_pconfig($uid,'appnet','token');
|
||||
$clientId = get_pconfig($uid,'appnet','clientid');
|
||||
$clientSecret = get_pconfig($uid,'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
$param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true,
|
||||
"include_html" => false, "include_post_annotations" => true);
|
||||
try {
|
||||
$thread = $app->getPostReplies($post["thread_id"], $param);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger("appnet_createpost: Error fetching thread for user ".$uid." ".appnet_error($e->getMessage()));
|
||||
}
|
||||
$thread = array_reverse($thread);
|
||||
|
||||
logger("appnet_createpost: fetched ".count($thread)." items for thread ".$post["thread_id"]." for user ".$uid, LOGGER_DEBUG);
|
||||
|
||||
foreach ($thread AS $tpost) {
|
||||
$threadpost = appnet_createpost($a, $uid, $tpost, $me, $user, $ownid, false, false);
|
||||
$item = item_store($threadpost);
|
||||
$threadpost["id"] = $item;
|
||||
|
||||
logger("appnet_createpost: stored post ".$post["id"]." thread ".$post["thread_id"]." in item ".$item, LOGGER_DEBUG);
|
||||
}
|
||||
//}
|
||||
}
|
||||
// Don't create accounts of people who just comment something
|
||||
$createuser = false;
|
||||
|
||||
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
|
||||
} else {
|
||||
$postarray['thr-parent'] = $postarray['uri'];
|
||||
$postarray['object-type'] = ACTIVITY_OBJ_NOTE;
|
||||
}
|
||||
|
||||
if (($post["user"]["id"] != $ownid) || ($postarray['thr-parent'] == $postarray['uri'])) {
|
||||
$postarray['owner-name'] = $post["user"]["name"];
|
||||
$postarray['owner-link'] = $post["user"]["canonical_url"];
|
||||
$postarray['owner-avatar'] = $post["user"]["avatar_image"]["url"];
|
||||
$postarray['contact-id'] = appnet_fetchcontact($a, $uid, $post["user"], $me, $createuser);
|
||||
} else {
|
||||
$postarray['owner-name'] = $me["name"];
|
||||
$postarray['owner-link'] = $me["url"];
|
||||
$postarray['owner-avatar'] = $me["thumb"];
|
||||
$postarray['contact-id'] = $me["id"];
|
||||
}
|
||||
|
||||
$links = array();
|
||||
|
||||
if (is_array($post["repost_of"])) {
|
||||
$postarray['author-name'] = $post["repost_of"]["user"]["name"];
|
||||
$postarray['author-link'] = $post["repost_of"]["user"]["canonical_url"];
|
||||
$postarray['author-avatar'] = $post["repost_of"]["user"]["avatar_image"]["url"];
|
||||
|
||||
$content = $post["repost_of"];
|
||||
} else {
|
||||
$postarray['author-name'] = $postarray['owner-name'];
|
||||
$postarray['author-link'] = $postarray['owner-link'];
|
||||
$postarray['author-avatar'] = $postarray['owner-avatar'];
|
||||
|
||||
$content = $post;
|
||||
}
|
||||
|
||||
$postarray['plink'] = $content["canonical_url"];
|
||||
|
||||
if (is_array($content["entities"])) {
|
||||
$converted = appnet_expand_entities($a, $content["text"], $content["entities"]);
|
||||
$postarray['body'] = $converted["body"];
|
||||
$postarray['tag'] = $converted["tags"];
|
||||
} else
|
||||
$postarray['body'] = $content["text"];
|
||||
|
||||
if (sizeof($content["entities"]["links"]))
|
||||
foreach($content["entities"]["links"] AS $link) {
|
||||
$url = normalise_link($link["url"]);
|
||||
$links[$url] = $link["url"];
|
||||
}
|
||||
|
||||
/* if (sizeof($content["annotations"]))
|
||||
foreach($content["annotations"] AS $annotation) {
|
||||
if ($annotation[type] == "net.app.core.oembed") {
|
||||
if (isset($annotation["value"]["embeddable_url"])) {
|
||||
$url = normalise_link($annotation["value"]["embeddable_url"]);
|
||||
if (isset($links[$url]))
|
||||
unset($links[$url]);
|
||||
}
|
||||
} elseif ($annotation[type] == "com.friendica.post") {
|
||||
//$links = array();
|
||||
//if (isset($annotation["value"]["post-title"]))
|
||||
// $postarray['title'] = $annotation["value"]["post-title"];
|
||||
|
||||
//if (isset($annotation["value"]["post-body"]))
|
||||
// $postarray['body'] = $annotation["value"]["post-body"];
|
||||
|
||||
//if (isset($annotation["value"]["post-tag"]))
|
||||
// $postarray['tag'] = $annotation["value"]["post-tag"];
|
||||
|
||||
if (isset($annotation["value"]["author-name"]))
|
||||
$postarray['author-name'] = $annotation["value"]["author-name"];
|
||||
|
||||
if (isset($annotation["value"]["author-link"]))
|
||||
$postarray['author-link'] = $annotation["value"]["author-link"];
|
||||
|
||||
if (isset($annotation["value"]["author-avatar"]))
|
||||
$postarray['author-avatar'] = $annotation["value"]["author-avatar"];
|
||||
}
|
||||
|
||||
} */
|
||||
|
||||
$page_info = "";
|
||||
|
||||
if (is_array($content["annotations"])) {
|
||||
$photo = appnet_expand_annotations($a, $content["annotations"]);
|
||||
if (($photo["large"] != "") && ($photo["url"] != ""))
|
||||
$page_info = "\n[url=".$photo["url"]."][img]".$photo["large"]."[/img][/url]";
|
||||
elseif ($photo["url"] != "")
|
||||
$page_info = "\n[img]".$photo["url"]."[/img]";
|
||||
|
||||
if ($photo["url"] != "")
|
||||
$postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
|
||||
|
||||
} else
|
||||
$photo = array("url" => "", "large" => "");
|
||||
|
||||
if (sizeof($links)) {
|
||||
$link = array_pop($links);
|
||||
$url = str_replace(array('/', '.'), array('\/', '\.'), $link);
|
||||
|
||||
$page_info = add_page_info($link, false, $photo["url"]);
|
||||
|
||||
if (trim($page_info) != "") {
|
||||
$removedlink = preg_replace("/\[url\=".$url."\](.*?)\[\/url\]/ism", '', $postarray['body']);
|
||||
if (($removedlink == "") || strstr($postarray['body'], $removedlink))
|
||||
$postarray['body'] = $removedlink;
|
||||
}
|
||||
}
|
||||
|
||||
$postarray['body'] .= $page_info;
|
||||
|
||||
$postarray['created'] = datetime_convert('UTC','UTC',$post["created_at"]);
|
||||
$postarray['edited'] = datetime_convert('UTC','UTC',$post["created_at"]);
|
||||
|
||||
$postarray['app'] = $post["source"]["name"];
|
||||
|
||||
return($postarray);
|
||||
}
|
||||
|
||||
function appnet_expand_entities($a, $body, $entities) {
|
||||
|
||||
if (!function_exists('substr_unicode')) {
|
||||
function substr_unicode($str, $s, $l = null) {
|
||||
return join("", array_slice(
|
||||
preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY), $s, $l));
|
||||
}
|
||||
}
|
||||
|
||||
$tags_arr = array();
|
||||
$replace = array();
|
||||
|
||||
foreach ($entities["mentions"] AS $mention) {
|
||||
$url = "@[url=https://alpha.app.net/".rawurlencode($mention["name"])."]".$mention["name"]."[/url]";
|
||||
$tags_arr["@".$mention["name"]] = $url;
|
||||
$replace[$mention["pos"]] = array("pos"=> $mention["pos"], "len"=> $mention["len"], "replace"=> $url);
|
||||
}
|
||||
|
||||
foreach ($entities["hashtags"] AS $hashtag) {
|
||||
$url = "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag["name"])."]".$hashtag["name"]."[/url]";
|
||||
$tags_arr["#".$hashtag["name"]] = $url;
|
||||
$replace[$hashtag["pos"]] = array("pos"=> $hashtag["pos"], "len"=> $hashtag["len"], "replace"=> $url);
|
||||
}
|
||||
|
||||
foreach ($entities["links"] AS $links) {
|
||||
$url = "[url=".$links["url"]."]".$links["text"]."[/url]";
|
||||
if (isset($links["amended_len"]) && ($links["amended_len"] > $links["len"]))
|
||||
$replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["amended_len"], "replace"=> $url);
|
||||
else
|
||||
$replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["len"], "replace"=> $url);
|
||||
}
|
||||
|
||||
|
||||
if (sizeof($replace)) {
|
||||
krsort($replace);
|
||||
foreach ($replace AS $entity) {
|
||||
$pre = substr_unicode($body, 0, $entity["pos"]);
|
||||
$post = substr_unicode($body, $entity["pos"] + $entity["len"]);
|
||||
//$pre = iconv_substr($body, 0, $entity["pos"], "UTF-8");
|
||||
//$post = iconv_substr($body, $entity["pos"] + $entity["len"], "UTF-8");
|
||||
|
||||
$body = $pre.$entity["replace"].$post;
|
||||
}
|
||||
}
|
||||
|
||||
return(array("body" => $body, "tags" => implode($tags_arr, ",")));
|
||||
}
|
||||
|
||||
function appnet_expand_annotations($a, $annotations) {
|
||||
$photo = array("url" => "", "large" => "");
|
||||
foreach ($annotations AS $annotation) {
|
||||
if (($annotation[type] == "net.app.core.oembed") &&
|
||||
($annotation["value"]["type"] == "photo")) {
|
||||
if ($annotation["value"]["url"] != "")
|
||||
$photo["url"] = $annotation["value"]["url"];
|
||||
|
||||
if ($annotation["value"]["thumbnail_large_url"] != "")
|
||||
$photo["large"] = $annotation["value"]["thumbnail_large_url"];
|
||||
|
||||
//if (($annotation["value"]["thumbnail_large_url"] != "") && ($annotation["value"]["url"] != ""))
|
||||
// $embedded = "\n[url=".$annotation["value"]["url"]."][img]".$annotation["value"]["thumbnail_large_url"]."[/img][/url]";
|
||||
//elseif ($annotation["value"]["url"] != "")
|
||||
// $embedded = "\n[img]".$annotation["value"]["url"]."[/img]";
|
||||
}
|
||||
}
|
||||
return $photo;
|
||||
}
|
||||
|
||||
function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) {
|
||||
|
||||
update_gcontact(array("url" => $contact["canonical_url"], "generation" => 2,
|
||||
"network" => NETWORK_APPNET, "photo" => $contact["avatar_image"]["url"],
|
||||
"name" => $contact["name"], "nick" => $contact["username"],
|
||||
"about" => $contact["description"]["text"], "hide" => true,
|
||||
"addr" => $contact["username"]."@app.net"));
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("adn::".$contact["id"]));
|
||||
|
||||
if(!count($r) && !$create_user)
|
||||
return($me["id"]);
|
||||
|
||||
if ($contact["canonical_url"] == "")
|
||||
return($me["id"]);
|
||||
|
||||
if (count($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
|
||||
logger("appnet_fetchcontact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if(!count($r)) {
|
||||
|
||||
if ($contact["name"] == "")
|
||||
$contact["name"] = $contact["username"];
|
||||
|
||||
if ($contact["username"] == "")
|
||||
$contact["username"] = $contact["name"];
|
||||
|
||||
// create contact record
|
||||
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
||||
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
||||
`about`, `writable`, `blocked`, `readonly`, `pending` )
|
||||
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, 0, 0, 0 ) ",
|
||||
intval($uid),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($contact["canonical_url"]),
|
||||
dbesc(normalise_link($contact["canonical_url"])),
|
||||
dbesc($contact["username"]."@app.net"),
|
||||
dbesc("adn::".$contact["id"]),
|
||||
dbesc(''),
|
||||
dbesc("adn::".$contact["id"]),
|
||||
dbesc($contact["name"]),
|
||||
dbesc($contact["username"]),
|
||||
dbesc($contact["avatar_image"]["url"]),
|
||||
dbesc(NETWORK_APPNET),
|
||||
intval(CONTACT_IS_FRIEND),
|
||||
intval(1),
|
||||
dbesc($contact["description"]["text"]),
|
||||
intval(1)
|
||||
);
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc("adn::".$contact["id"]),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if(! count($r))
|
||||
return(false);
|
||||
|
||||
$contact_id = $r[0]['id'];
|
||||
|
||||
$g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if($g && intval($g[0]['def_gid'])) {
|
||||
require_once('include/group.php');
|
||||
group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
|
||||
}
|
||||
|
||||
require_once("Photo.php");
|
||||
|
||||
$photos = import_profile_photo($contact["avatar_image"]["url"],$uid,$contact_id);
|
||||
|
||||
q("UPDATE `contact` SET `photo` = '%s',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s'
|
||||
WHERE `id` = %d",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact_id)
|
||||
);
|
||||
} else {
|
||||
// update profile photos once every two weeks as we have no notification of when they change.
|
||||
|
||||
//$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false);
|
||||
$update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
|
||||
|
||||
// check that we have all the photos, this has been known to fail on occasion
|
||||
|
||||
if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) {
|
||||
|
||||
logger("appnet_fetchcontact: Updating contact ".$contact["username"], LOGGER_DEBUG);
|
||||
|
||||
require_once("Photo.php");
|
||||
|
||||
$photos = import_profile_photo($contact["avatar_image"]["url"], $uid, $r[0]['id']);
|
||||
|
||||
q("UPDATE `contact` SET `photo` = '%s',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s',
|
||||
`url` = '%s',
|
||||
`nurl` = '%s',
|
||||
`addr` = '%s',
|
||||
`name` = '%s',
|
||||
`nick` = '%s',
|
||||
`about` = '%s'
|
||||
WHERE `id` = %d",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($contact["canonical_url"]),
|
||||
dbesc(normalise_link($contact["canonical_url"])),
|
||||
dbesc($contact["username"]."@app.net"),
|
||||
dbesc($contact["name"]),
|
||||
dbesc($contact["username"]),
|
||||
dbesc($contact["description"]["text"]),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return($r[0]["id"]);
|
||||
}
|
||||
|
||||
function appnet_prepare_body(&$a,&$b) {
|
||||
if ($b["item"]["network"] != NETWORK_APPNET)
|
||||
return;
|
||||
|
||||
if ($b["preview"]) {
|
||||
$max_char = 256;
|
||||
require_once("include/plaintext.php");
|
||||
$item = $b["item"];
|
||||
$item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
|
||||
|
||||
$r = q("SELECT `author-link` FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
|
||||
dbesc($item["thr-parent"]),
|
||||
intval(local_user()));
|
||||
|
||||
if(count($r)) {
|
||||
$orig_post = $r[0];
|
||||
|
||||
$nicknameplain = preg_replace("=https?://alpha.app.net/(.*)=ism", "$1", $orig_post["author-link"]);
|
||||
$nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
|
||||
$nicknameplain = "@".$nicknameplain;
|
||||
|
||||
if ((strpos($item["body"], $nickname) === false) && (strpos($item["body"], $nicknameplain) === false))
|
||||
$item["body"] = $nickname." ".$item["body"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$msgarr = plaintext($a, $item, $max_char, true);
|
||||
$msg = appnet_create_entities($a, $item, $msgarr);
|
||||
|
||||
require_once("library/markdown.php");
|
||||
$msg = Markdown($msg);
|
||||
|
||||
$b['html'] = $msg;
|
||||
}
|
||||
}
|
||||
|
||||
function appnet_cron($a,$b) {
|
||||
$last = get_config('appnet','last_poll');
|
||||
|
||||
$poll_interval = intval(get_config('appnet','poll_interval'));
|
||||
if(! $poll_interval)
|
||||
$poll_interval = APPNET_DEFAULT_POLL_INTERVAL;
|
||||
|
||||
if($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
if($next > time()) {
|
||||
logger('appnet_cron: poll intervall not reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
logger('appnet_cron: cron_start');
|
||||
|
||||
$abandon_days = intval(get_config('system','account_abandon_days'));
|
||||
if ($abandon_days < 1)
|
||||
$abandon_days = 0;
|
||||
|
||||
$abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400);
|
||||
|
||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'appnet' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
||||
if(count($r)) {
|
||||
foreach($r as $rr) {
|
||||
if ($abandon_days != 0) {
|
||||
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
|
||||
if (!count($user)) {
|
||||
logger('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
logger('appnet_cron: importing timeline from user '.$rr['uid']);
|
||||
appnet_fetchstream($a, $rr["uid"]);
|
||||
}
|
||||
}
|
||||
|
||||
logger('appnet_cron: cron_end');
|
||||
|
||||
set_config('appnet','last_poll', time());
|
||||
}
|
||||
|
||||
function appnet_error($msg) {
|
||||
$msg = trim($msg);
|
||||
$pos = strrpos($msg, "\r\n\r\n");
|
||||
|
||||
if (!$pos)
|
||||
return($msg);
|
||||
|
||||
$msg = substr($msg, $pos + 4);
|
||||
|
||||
$error = json_decode($msg);
|
||||
|
||||
if ($error == NULL)
|
||||
return($msg);
|
||||
|
||||
if (isset($error->meta->error_message))
|
||||
return($error->meta->error_message);
|
||||
else
|
||||
return(print_r($error));
|
||||
}
|
||||
62
appnet/clients.txt
Normal file
62
appnet/clients.txt
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
PDvZfuW8zhzjwU8PF9KEzFbAcTn6T67U - http://wedge.natestedman.com - Wedge
|
||||
cRWp45kA49pQKtxsZQXdwTnyuU6jBwuA - http://tigerbears.com/felix - Felix
|
||||
ks4empDNRbXEAauk8BhLTdSvfEeAABvX - http://kiwi-app.net/ - Kiwi
|
||||
nxz5USfARxELsYVpfPJc3mYaX42USb2E - http://themodernink.com/portfolio/dash-for-app-net/ - Dash
|
||||
PvANLyCeaDjbMt6VCVWhKvUmgX6TxDXj - https://cauldron-app.herokuapp.com - Cauldron
|
||||
737a54nLCdLLutcs2VzhtNKGnnMrakc4 - http://riposteapp.net - Riposte
|
||||
j2TPZ4DyNa8GGhVUrTQJg9qWDw7t6fBn - http://blixt.io - Blixt
|
||||
5vL9wT7EU7NRgk3hXscWW8Q27D2rYJCP - http://dasdom.de/Dominik_Hauser_Development/hAppy.html - hAppy
|
||||
caYWDBvjwt2e9HWMm6qyKS6KcATHUkzQ - https://alpha.app.net - Alpha
|
||||
gM5cMMBD7JJ6xamnBTcbhzkDCnR7xAux - http://robinapp.net - Robin
|
||||
35UhKXbTqxmE7Hs427haVuRVB8FGzhtx - http://www.floodgap.com/software/texapp/ - Texapp
|
||||
QHhyYpuARCwurZdGuuR7zjDMHDRkwcKm - http://tapbots.com/software/netbot - Netbot for iOS
|
||||
xpFjFqgMv2BMtbHJZTFe7JRWsYJSUuHr - http://ferret.undiscoveredsoftware.com - Ferret
|
||||
SzuHyL9wQy2BN7DDnBvdXpZr9Ue5MHYd - http://appnetizens.com - Appnetizens
|
||||
C8NUX9JhL8uTW5EERQUTdXxWA3VQQ7Ft - http://dabr.eu/adn/ - Dabr - The Best Mobile Web Experience for App.net
|
||||
NMYk2JjsJErGuYrjztFqZTcfH6ewq4Vs - http://pilgrimagesoftware.com/products/yawp - Yawp
|
||||
nwpvwKVqxmEzZ6bEwkv53yaJABVj9ngQ - http://www.windowsphone.com/en-us/store/app/dotdot/dd4e94db-0e2a-4cfb-8c28-8b969e47c3c4 - DotDot
|
||||
f7AUb7Akar3WbnUWbpfkgUDAZF777tLT - http://treeview.us/ - TreeView
|
||||
qeqDYzScwCt6zprQTTByapLAHwm24Dgv - http://hashpan.com - #PAN
|
||||
DhUuGUGFnf9PrJmREsKtQDGB4tz3xUqL - http://chimp.li/ - Chimp
|
||||
bCyhhBHxCRRAPHJNcLXxxS2KWk4Jq8cg - https://bit.ly/1415pJs - Blue
|
||||
js4qF6UN4fwXTK87Ax9Bjf3DhEQuK5hA - https://pirati.ca - friendica
|
||||
QsqkRF7XkqnTyST8YPtJwbKt4v7cnk4u - http://kirbyapp.azurewebsites.net - Kirby
|
||||
3MTzAfxABSvAXxGs4878jd6ynDJShMKV - https://pastapp.net - Pastapp
|
||||
2JdaX6Ysmxb3UbfnGmHQwGxGWMM28q2P - http://ineedtojet.com/drift/ - Drift
|
||||
B58XbrGstDUXvSKxDTxV7FGSStH6vfJZ - http://alpha.jvimedia.org - alpha.jvimedia.org
|
||||
hFsCGArAjgJkYBHTHbZnUvzTmL4vaLHL - http://www.ayadn-app.net - Ayadn
|
||||
e6pkUJsErZQMpKSfEqH693Yw2r4JAkUx - http://shawnthroop.com/prose - Prose
|
||||
KgWW36vGe8LQPN696ftSUqdKUvjzuYqF - https://polls.abrah.am - Polls
|
||||
424RQtjWS96PQj2KzDzHStWdNazS4naL - http://bli.ms - BLI.MS
|
||||
Awm347m2hfLu2VZTYvmPq3FkMnXUtjvu - http://monkeystew.org - littlebit
|
||||
8uJC3sb9PT5AYgUj2DajfXa9WuFj7P3a - http://getstreamapp.net/ - Stream
|
||||
q6BSdP5DctemahG9EDZVAmCv2x2dbjZJ - https://github.com/appdotnet/adn-comments - App.net Comments
|
||||
GfhV6dxDc8pERRas7CmSPtpdqcXYQv8G - http://favd.net - Favd
|
||||
YEpw9MQ9XuBq587pFWDAVRPTsteLUhya - https://hootsuite.com - HootSuite for App.net
|
||||
zEKkE4JBYNjnarYvEwGZxvFq7zuhEfnU - http://grailbox.com/wry - Wry
|
||||
w98ZmPF4RSMuyrhPzNHrJBVm89GNmGnJ - http://www.tweetlanes.com - Tweet Lanes
|
||||
92JGb2kLrhsPFER8CAZezHgBGpdZ3XYC - http://vidcast-app.net/ - Vidcast
|
||||
qjpU52DDXuurvMw65gzNbv7XCreV5v3m - https://github.com/minego/macaw-enyo - Macaw
|
||||
Ab2jgbmdrz9Kjk49AKmDSDsGNt4cq4H8 - http://shootingstar.fm/asterisk/ - Asterisk(仮)
|
||||
QRLNj42zZ8KVkBgs6Jm5KwHu98Zs3YTu - https://play.google.com/store/apps/details?id=com.matsumo.bb - アオイトリ(bluebird)
|
||||
gK89yfgAr8qxH9HZf8nbhry8Snc5fRGV - http://aa.tt/sprinter-ios - Sprinter
|
||||
X2hcReHMUuK7Mx3uTxGRPnYeCrugx5JX - http://getzephyrapp.com - Zephyr
|
||||
FS62JKk5qYppVA8JWhZvPepU7A33PXtD - http://www.instadesk-app.com/appetizer - Appetizer
|
||||
gxwZjynDJw4TjPPwk3z4YMs9fJBNSxVm - http://www.nymphicusapp.com/chapper/ - Chapper
|
||||
QAH95svvU4pewJ5aKkpyCdUvyzMsBxBk - https://alpha.app.net/network - The Network
|
||||
WXJyQ6KK2TWy6ZDnJqJKbBDMrzPYYA3g - http://neater.co - Neater
|
||||
PeVWEPMAEQMBwU2KLSYAjenRrScuWs4a - http://fingernoodle.com/Mention - Mention
|
||||
Sza4zFMDcbmYqeCCjTusZNpP9DqWEwqJ - http://colorbay.me - Colorbay
|
||||
cgedd8JNuBcEZfjCstsk74J9hxKnBYef - http://www.MetroAppNet.com - MetroAppNet
|
||||
rsQM4njhnZnSe2Jaqsw5eVZQHLcM37wv - http://mobileways.de/gravity - Gravity
|
||||
4M5FBt9NRk5Zu4FqaWcGZHj84ryUxwXh - http://habitatus.net/photolicious - Photolicious
|
||||
D7vDLagx2fyBrqvGRyH6qZkdQAFvETv8 - http://206.81.100.17:8000/ - Alpha Test
|
||||
ZcFNVDbEhCTc79z9ALaGbxuvXRqTdDAS - http://watercoolerapp.net - Watercooler
|
||||
BHKWNEYrz3Fv5CzgvksK6pydcAE6q52r - http://rivolu.com/spoonbill - Spoonbill
|
||||
dxZBcnnPjcV4ErwbjArvbGBHMcnW4SMB - https://play.google.com/store/apps/details?id=jp.hamsoft.hamoooooon&hl=ja - Hamoooooon
|
||||
hSyCNZrLZCZHcmsHr6cLFMF2pwQpRmZP - http://getpika.com - Pika
|
||||
9gbNKzXYsyzErU9K2J7v88XaFRfwsDzN - http://www.planet1107.net - AppNet Rhino
|
||||
tyLnvDZJPX37U8gZ6WtZ2Ysf9kpTmRXy - https://play.google.com/store/apps/details?id=com.floatboth.antigravity - Antigravity
|
||||
GLSssckvDjzbCa27B8HZVjJ2DPZgGJL3 - http://lunarguard.co/ - Pegasus
|
||||
dyJyAJa535BMjqYBQsgftREbxsqdcVLL - http://www.flamingow.com - Flamingow
|
||||
u6TeYE9yYprhkWPjVNgacJLngkhVrDFw - http://rafaelc.com.br - Sweet(dot)net for iOS
|
||||
60
appnet/count.php
Normal file
60
appnet/count.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
require_once("boot.php");
|
||||
|
||||
if(@is_null($a)) {
|
||||
$a = new App;
|
||||
}
|
||||
|
||||
@include(".htconfig.php");
|
||||
require_once("dba.php");
|
||||
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
||||
unset($db_host, $db_user, $db_pass, $db_data);
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
$token = get_pconfig($b['uid'],'appnet','token');
|
||||
|
||||
require_once 'addon/appnet/AppDotNet.php';
|
||||
|
||||
$clientId = get_pconfig($b["uid"],'appnet','clientid');
|
||||
$clientSecret = get_pconfig($b["uid"],'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
$param = array("include_muted" => true, "include_directed_posts" => true, "count" => 3000);
|
||||
|
||||
$lastid = @file_get_contents("addon/appnet/lastid.txt");
|
||||
$clients = @file_get_contents("addon/appnet/clients.txt");
|
||||
$users = @file_get_contents("addon/appnet/users.txt");
|
||||
|
||||
if ($lastid != "")
|
||||
$param["since_id"] = $lastid;
|
||||
|
||||
$posts = $app->getPublicPosts($param);
|
||||
|
||||
foreach ($posts AS $post) {
|
||||
if ($lastid < $post["id"])
|
||||
$lastid = $post["id"];
|
||||
|
||||
if (!isset($post["reply_to"]) AND !strstr($clients, $post["source"]["client_id"]))
|
||||
continue;
|
||||
|
||||
if (isset($post["reply_to"]) AND !strstr($clients, $post["source"]["client_id"]))
|
||||
$clients .= $post["source"]["client_id"]." - ".$post["source"]["link"]." - ".$post["source"]["name"]."\n";
|
||||
|
||||
if (!strstr($users, $post["user"]["canonical_url"]))
|
||||
$users .= $post["user"]["canonical_url"]." - ".$post["user"]["name"]."\n";
|
||||
|
||||
//echo $post["source"]["link"]." ".$post["source"]["name"]."\n";
|
||||
//echo $post["user"]["name"]."\n";
|
||||
//echo $post["text"]."\n";
|
||||
//echo $post["canonical_url"]."\n";
|
||||
//print_r($post["user"]);
|
||||
//echo "---------------------------------\n";
|
||||
|
||||
}
|
||||
|
||||
file_put_contents("addon/appnet/lastid.txt", $lastid);
|
||||
file_put_contents("addon/appnet/clients.txt", $clients);
|
||||
file_put_contents("addon/appnet/users.txt", $users);
|
||||
116
appnet/lang/C/messages.po
Normal file
116
appnet/lang/C/messages.po
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try again."
|
||||
"</p>"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a href=\"https://account.app.net/"
|
||||
"developer/apps/\">https://account.app.net/developer/apps/</a> and enter "
|
||||
"Client ID and Client Secret. "
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/"
|
||||
"\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr ""
|
||||
118
appnet/lang/cs/messages.po
Normal file
118
appnet/lang/cs/messages.po
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
# Translators:
|
||||
# Michal Šupler <msupler@gmail.com>, 2014
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: 2014-07-02 15:24+0000\n"
|
||||
"Last-Translator: Michal Šupler <msupler@gmail.com>\n"
|
||||
"Language-Team: Czech (http://www.transifex.com/projects/p/friendica/language/cs/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: cs\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr "Přístup odmítnut."
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr "Nyní jste přihlášen k app.net."
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr "<p>Chyba v přenesení tokenu. Prosím zkuste to znovu.</p>"
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr "návrat ke stránce konektor"
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr "Poslat příspěvek na app.net"
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr "App.net Export"
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr "V současné době připojen k:"
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr "Aktivovat App.net Post Plugin"
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr "Defaultně poslat na App.net"
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr "Importovat vzdálenou časovou osu"
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try "
|
||||
"again.</p>"
|
||||
msgstr "<p>Chyba v přenesení uživatelského profilu. Prosím zkuste smazat konfiguraci a zkusit to znovu.</p>"
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr "<p>Máte nyní dvě možnosti jak se připojit k App.net.</p>"
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a "
|
||||
"href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a>"
|
||||
" and enter Client ID and Client Secret. "
|
||||
msgstr "<p>První možnost: Registrovat svou žádost na <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> a zadat Client ID and Client Secret. "
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr "Použít '%s' jako URI pro přesměrování<p>"
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr "Client ID"
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr "Client Secret"
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-"
|
||||
"lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr "<p>Druhá možnost: vložit token do <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr "Nastavte tyto rámce: 'Základní', 'Stream', 'Psaní příspěvků, 'Veřejné zprávy', 'Zprávy'.</p>"
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr "Token"
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr "Přihlásit se s použitím App.net"
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr "Vymazat konfiguraci OAuth"
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr "Uložit Nastavení"
|
||||
29
appnet/lang/cs/strings.php
Normal file
29
appnet/lang/cs/strings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(! function_exists("string_plural_select_cs")) {
|
||||
function string_plural_select_cs($n){
|
||||
return ($n==1) ? 0 : ($n>=2 && $n<=4) ? 1 : 2;;
|
||||
}}
|
||||
;
|
||||
$a->strings["Permission denied."] = "Přístup odmítnut.";
|
||||
$a->strings["You are now authenticated to app.net. "] = "Nyní jste přihlášen k app.net.";
|
||||
$a->strings["<p>Error fetching token. Please try again.</p>"] = "<p>Chyba v přenesení tokenu. Prosím zkuste to znovu.</p>";
|
||||
$a->strings["return to the connector page"] = "návrat ke stránce konektor";
|
||||
$a->strings["Post to app.net"] = "Poslat příspěvek na app.net";
|
||||
$a->strings["App.net Export"] = "App.net Export";
|
||||
$a->strings["Currently connected to: "] = "V současné době připojen k:";
|
||||
$a->strings["Enable App.net Post Plugin"] = "Aktivovat App.net Post Plugin";
|
||||
$a->strings["Post to App.net by default"] = "Defaultně poslat na App.net";
|
||||
$a->strings["Import the remote timeline"] = "Importovat vzdálenou časovou osu";
|
||||
$a->strings["<p>Error fetching user profile. Please clear the configuration and try again.</p>"] = "<p>Chyba v přenesení uživatelského profilu. Prosím zkuste smazat konfiguraci a zkusit to znovu.</p>";
|
||||
$a->strings["<p>You have two ways to connect to App.net.</p>"] = "<p>Máte nyní dvě možnosti jak se připojit k App.net.</p>";
|
||||
$a->strings["<p>First way: Register an application at <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. "] = "<p>První možnost: Registrovat svou žádost na <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> a zadat Client ID and Client Secret. ";
|
||||
$a->strings["Use '%s' as Redirect URI<p>"] = "Použít '%s' jako URI pro přesměrování<p>";
|
||||
$a->strings["Client ID"] = "Client ID";
|
||||
$a->strings["Client Secret"] = "Client Secret";
|
||||
$a->strings["<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "] = "<p>Druhá možnost: vložit token do <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. ";
|
||||
$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"] = "Nastavte tyto rámce: 'Základní', 'Stream', 'Psaní příspěvků, 'Veřejné zprávy', 'Zprávy'.</p>";
|
||||
$a->strings["Token"] = "Token";
|
||||
$a->strings["Sign in using App.net"] = "Přihlásit se s použitím App.net";
|
||||
$a->strings["Clear OAuth configuration"] = "Vymazat konfiguraci OAuth";
|
||||
$a->strings["Save Settings"] = "Uložit Nastavení";
|
||||
118
appnet/lang/de/messages.po
Normal file
118
appnet/lang/de/messages.po
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
# Translators:
|
||||
# bavatar <tobias.diekershoff@gmx.net>, 2014
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: 2014-06-25 04:31+0000\n"
|
||||
"Last-Translator: bavatar <tobias.diekershoff@gmx.net>\n"
|
||||
"Language-Team: German (http://www.transifex.com/projects/p/friendica/language/de/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: de\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr "Zugriff verweigert."
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr "Du bist nun auf app.net authentifiziert."
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr "<p>Fehler beim Holen des Tokens, bitte versuche es später noch einmal.</p>"
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr "zurück zur Connector Seite"
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr "Nach app.net senden"
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr "App.net Export"
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr "Momentan verbunden mit: "
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr "Veröffentlichungen bei App.net erlauben"
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr "Standardmäßig bei App.net veröffentlichen"
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr "Importiere die entfernte Zeitleiste"
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try "
|
||||
"again.</p>"
|
||||
msgstr "<p>Beim Laden des Nutzerprofils ist ein Fehler aufgetreten. Bitte versuche es später noch einmal.</p>"
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr "<p>Du hast zwei Wege deinen friendica Account mit App.net zu verbinden.</p>"
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a "
|
||||
"href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a>"
|
||||
" and enter Client ID and Client Secret. "
|
||||
msgstr "<p>Erster Weg: Registriere eine Anwendung unter <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> und wähle eine Client ID und ein Client Secret."
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr "Verwende '%s' als Redirect URI<p>"
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr "Client ID"
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr "Client Secret"
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-"
|
||||
"lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr "<p>Zweiter Weg: Beantrage ein Token unter <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr "Verwende folgende Scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr "Token"
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr "Per App.net anmelden"
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr "OAuth Konfiguration löschen"
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr "Einstellungen speichern"
|
||||
29
appnet/lang/de/strings.php
Normal file
29
appnet/lang/de/strings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(! function_exists("string_plural_select_de")) {
|
||||
function string_plural_select_de($n){
|
||||
return ($n != 1);;
|
||||
}}
|
||||
;
|
||||
$a->strings["Permission denied."] = "Zugriff verweigert.";
|
||||
$a->strings["You are now authenticated to app.net. "] = "Du bist nun auf app.net authentifiziert.";
|
||||
$a->strings["<p>Error fetching token. Please try again.</p>"] = "<p>Fehler beim Holen des Tokens, bitte versuche es später noch einmal.</p>";
|
||||
$a->strings["return to the connector page"] = "zurück zur Connector Seite";
|
||||
$a->strings["Post to app.net"] = "Nach app.net senden";
|
||||
$a->strings["App.net Export"] = "App.net Export";
|
||||
$a->strings["Currently connected to: "] = "Momentan verbunden mit: ";
|
||||
$a->strings["Enable App.net Post Plugin"] = "Veröffentlichungen bei App.net erlauben";
|
||||
$a->strings["Post to App.net by default"] = "Standardmäßig bei App.net veröffentlichen";
|
||||
$a->strings["Import the remote timeline"] = "Importiere die entfernte Zeitleiste";
|
||||
$a->strings["<p>Error fetching user profile. Please clear the configuration and try again.</p>"] = "<p>Beim Laden des Nutzerprofils ist ein Fehler aufgetreten. Bitte versuche es später noch einmal.</p>";
|
||||
$a->strings["<p>You have two ways to connect to App.net.</p>"] = "<p>Du hast zwei Wege deinen friendica Account mit App.net zu verbinden.</p>";
|
||||
$a->strings["<p>First way: Register an application at <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. "] = "<p>Erster Weg: Registriere eine Anwendung unter <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> und wähle eine Client ID und ein Client Secret.";
|
||||
$a->strings["Use '%s' as Redirect URI<p>"] = "Verwende '%s' als Redirect URI<p>";
|
||||
$a->strings["Client ID"] = "Client ID";
|
||||
$a->strings["Client Secret"] = "Client Secret";
|
||||
$a->strings["<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "] = "<p>Zweiter Weg: Beantrage ein Token unter <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. ";
|
||||
$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"] = "Verwende folgende Scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>";
|
||||
$a->strings["Token"] = "Token";
|
||||
$a->strings["Sign in using App.net"] = "Per App.net anmelden";
|
||||
$a->strings["Clear OAuth configuration"] = "OAuth Konfiguration löschen";
|
||||
$a->strings["Save Settings"] = "Einstellungen speichern";
|
||||
118
appnet/lang/es/messages.po
Normal file
118
appnet/lang/es/messages.po
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
# Translators:
|
||||
# Alberto Díaz Tormo <albertodiaztormo@gmail.com>, 2016
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: 2016-10-13 21:25+0000\n"
|
||||
"Last-Translator: Alberto Díaz Tormo <albertodiaztormo@gmail.com>\n"
|
||||
"Language-Team: Spanish (http://www.transifex.com/Friendica/friendica/language/es/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: es\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr "Permiso denegado"
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr "Ahora está autenticado en app.net."
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr "<p>Advertencia de error. Por favor inténtelo de nuevo.</p>"
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr "vuelva a pa página de conexón"
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr "Publique en app.net"
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr "Exportar a app.net"
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr "Actualmente conectado a:"
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr "Habilitar el plugin de publicación de App.net"
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr "Publicar en App.net por defecto"
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr "Importar la línea de tiempo remota"
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try "
|
||||
"again.</p>"
|
||||
msgstr "<p>Advertencia de error de perfil. Por favor borre la configuración e inténtelo de nuevo.</p>"
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr "<p>Tiene dos formas de conectar a App.net.</p>"
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a "
|
||||
"href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a>"
|
||||
" and enter Client ID and Client Secret. "
|
||||
msgstr "<p>Primera forma: Registrar una aplicación en <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> y seleccionar Client ID y Client Secret. "
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr "Use '%s' como Redirigir URI"
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr "ID de cliente"
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr "Secreto de cliente"
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-"
|
||||
"lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr "<p>Segunda manera: traiga un símbolo a <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>"
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr "Seleccione estas posibilidades: 'Básico', 'Continuo', 'Escribir entrada', 'Mensajes públicos', 'Mensajes'.</p>"
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr "Símbolo"
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr "Regístrese usando App.net"
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr "Borre la configuración OAuth"
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr "Guardar los ajustes"
|
||||
29
appnet/lang/es/strings.php
Normal file
29
appnet/lang/es/strings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(! function_exists("string_plural_select_es")) {
|
||||
function string_plural_select_es($n){
|
||||
return ($n != 1);;
|
||||
}}
|
||||
;
|
||||
$a->strings["Permission denied."] = "Permiso denegado";
|
||||
$a->strings["You are now authenticated to app.net. "] = "Ahora está autenticado en app.net.";
|
||||
$a->strings["<p>Error fetching token. Please try again.</p>"] = "<p>Advertencia de error. Por favor inténtelo de nuevo.</p>";
|
||||
$a->strings["return to the connector page"] = "vuelva a pa página de conexón";
|
||||
$a->strings["Post to app.net"] = "Publique en app.net";
|
||||
$a->strings["App.net Export"] = "Exportar a app.net";
|
||||
$a->strings["Currently connected to: "] = "Actualmente conectado a:";
|
||||
$a->strings["Enable App.net Post Plugin"] = "Habilitar el plugin de publicación de App.net";
|
||||
$a->strings["Post to App.net by default"] = "Publicar en App.net por defecto";
|
||||
$a->strings["Import the remote timeline"] = "Importar la línea de tiempo remota";
|
||||
$a->strings["<p>Error fetching user profile. Please clear the configuration and try again.</p>"] = "<p>Advertencia de error de perfil. Por favor borre la configuración e inténtelo de nuevo.</p>";
|
||||
$a->strings["<p>You have two ways to connect to App.net.</p>"] = "<p>Tiene dos formas de conectar a App.net.</p>";
|
||||
$a->strings["<p>First way: Register an application at <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. "] = "<p>Primera forma: Registrar una aplicación en <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> y seleccionar Client ID y Client Secret. ";
|
||||
$a->strings["Use '%s' as Redirect URI<p>"] = "Use '%s' como Redirigir URI";
|
||||
$a->strings["Client ID"] = "ID de cliente";
|
||||
$a->strings["Client Secret"] = "Secreto de cliente";
|
||||
$a->strings["<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "] = "<p>Segunda manera: traiga un símbolo a <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>";
|
||||
$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"] = "Seleccione estas posibilidades: 'Básico', 'Continuo', 'Escribir entrada', 'Mensajes públicos', 'Mensajes'.</p>";
|
||||
$a->strings["Token"] = "Símbolo";
|
||||
$a->strings["Sign in using App.net"] = "Regístrese usando App.net";
|
||||
$a->strings["Clear OAuth configuration"] = "Borre la configuración OAuth";
|
||||
$a->strings["Save Settings"] = "Guardar los ajustes";
|
||||
119
appnet/lang/fr/messages.po
Normal file
119
appnet/lang/fr/messages.po
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
# Translators:
|
||||
# Hypolite Petovan <mrpetovan@gmail.com>, 2016
|
||||
# Jak <jacques@riseup.net>, 2014
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: 2016-09-24 02:12+0000\n"
|
||||
"Last-Translator: Hypolite Petovan <mrpetovan@gmail.com>\n"
|
||||
"Language-Team: French (http://www.transifex.com/Friendica/friendica/language/fr/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: fr\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr "Autorisation refusée"
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr "Vous êtes maintenant authentifié sur app.net"
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr "<p>Impossible d'obtenir le jeton, merci de réessayer.</p>"
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr "revenir à la page du connecteur"
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr "Publier sur app.net"
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr "Export App.net"
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr "Actuellement connecté à :"
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr "Activer le plugin de publication app.net"
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr "Publier sur App.net par défaut"
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr "Importer la timeline distante"
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try "
|
||||
"again.</p>"
|
||||
msgstr "<p>Impossible d'obtenir le profil utilisateur. Merci de réinitialiser la configuration et de réessayer.</p>"
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr "<p>Vous avez deux possibilités pour vous connecter à App.net.</p>"
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a "
|
||||
"href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a>"
|
||||
" and enter Client ID and Client Secret. "
|
||||
msgstr "<p>Première méthode: Enregistrer une application sur <a href=\"https://account.app.net/developer/apps/\">App.net [en]</a> et entrez l'ID Client et le Secret Client. "
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr "Utilisez '%s' pour l'URI de Redirection"
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr "ID Client"
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr "Secret Client"
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-"
|
||||
"lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr "<p>Deuxième méthode: obtenez un jeton ur <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/ [en]</a>. "
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr "Cochez les \"scopes\" suivant: \"Basic\", \"Stream\", \"Write Post\", \"Public Messages\", \"Messages\".</p>"
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr "Jeton"
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr "Se connecter avec App.net"
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr "Effacer la configuration OAuth"
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr "Sauvegarder les paramètres"
|
||||
29
appnet/lang/fr/strings.php
Normal file
29
appnet/lang/fr/strings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(! function_exists("string_plural_select_fr")) {
|
||||
function string_plural_select_fr($n){
|
||||
return ($n > 1);;
|
||||
}}
|
||||
;
|
||||
$a->strings["Permission denied."] = "Autorisation refusée";
|
||||
$a->strings["You are now authenticated to app.net. "] = "Vous êtes maintenant authentifié sur app.net";
|
||||
$a->strings["<p>Error fetching token. Please try again.</p>"] = "<p>Impossible d'obtenir le jeton, merci de réessayer.</p>";
|
||||
$a->strings["return to the connector page"] = "revenir à la page du connecteur";
|
||||
$a->strings["Post to app.net"] = "Publier sur app.net";
|
||||
$a->strings["App.net Export"] = "Export App.net";
|
||||
$a->strings["Currently connected to: "] = "Actuellement connecté à :";
|
||||
$a->strings["Enable App.net Post Plugin"] = "Activer le plugin de publication app.net";
|
||||
$a->strings["Post to App.net by default"] = "Publier sur App.net par défaut";
|
||||
$a->strings["Import the remote timeline"] = "Importer la timeline distante";
|
||||
$a->strings["<p>Error fetching user profile. Please clear the configuration and try again.</p>"] = "<p>Impossible d'obtenir le profil utilisateur. Merci de réinitialiser la configuration et de réessayer.</p>";
|
||||
$a->strings["<p>You have two ways to connect to App.net.</p>"] = "<p>Vous avez deux possibilités pour vous connecter à App.net.</p>";
|
||||
$a->strings["<p>First way: Register an application at <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. "] = "<p>Première méthode: Enregistrer une application sur <a href=\"https://account.app.net/developer/apps/\">App.net [en]</a> et entrez l'ID Client et le Secret Client. ";
|
||||
$a->strings["Use '%s' as Redirect URI<p>"] = "Utilisez '%s' pour l'URI de Redirection";
|
||||
$a->strings["Client ID"] = "ID Client";
|
||||
$a->strings["Client Secret"] = "Secret Client";
|
||||
$a->strings["<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "] = "<p>Deuxième méthode: obtenez un jeton ur <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/ [en]</a>. ";
|
||||
$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"] = "Cochez les \"scopes\" suivant: \"Basic\", \"Stream\", \"Write Post\", \"Public Messages\", \"Messages\".</p>";
|
||||
$a->strings["Token"] = "Jeton";
|
||||
$a->strings["Sign in using App.net"] = "Se connecter avec App.net";
|
||||
$a->strings["Clear OAuth configuration"] = "Effacer la configuration OAuth";
|
||||
$a->strings["Save Settings"] = "Sauvegarder les paramètres";
|
||||
118
appnet/lang/it/messages.po
Normal file
118
appnet/lang/it/messages.po
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
# Translators:
|
||||
# fabrixxm <fabrix.xm@gmail.com>, 2014
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: 2014-09-10 10:18+0000\n"
|
||||
"Last-Translator: fabrixxm <fabrix.xm@gmail.com>\n"
|
||||
"Language-Team: Italian (http://www.transifex.com/Friendica/friendica/language/it/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: it\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr "Permesso negato."
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr "Sei autenticato su app.net"
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr "<p>Errore recuperando il token. Prova di nuovo</p>"
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr "ritorna alla pagina del connettore"
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr "Invia ad app.net"
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr "Esporta App.net"
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr "Al momento connesso con:"
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr "Abilita il plugin di invio ad App.net"
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr "Invia sempre ad App.net"
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr "Importa la timeline remota"
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try "
|
||||
"again.</p>"
|
||||
msgstr "<p>Errore recuperando il profilo utente. Svuota la configurazione e prova di nuovo.</p>"
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr "<p>Puoi collegarti ad App.net in due modi.</p>"
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a "
|
||||
"href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a>"
|
||||
" and enter Client ID and Client Secret. "
|
||||
msgstr "<p>Registrare un'applicazione su <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> e inserire Client ID e Client Secret."
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr "Usa '%s' come Redirect URI</p>"
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr "Client ID"
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr "Client Secret"
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-"
|
||||
"lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr "<p>Oppure puoi recuperare un token su <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>."
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr "Imposta gli ambiti 'Basic', 'Stream', 'Scrivi Post', 'Messaggi Pubblici', 'Messaggi'.</p>"
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr "Token"
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr "Autenticati con App.net"
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr "Pulisci configurazione OAuth"
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr "Salva Impostazioni"
|
||||
29
appnet/lang/it/strings.php
Normal file
29
appnet/lang/it/strings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(! function_exists("string_plural_select_it")) {
|
||||
function string_plural_select_it($n){
|
||||
return ($n != 1);;
|
||||
}}
|
||||
;
|
||||
$a->strings["Permission denied."] = "Permesso negato.";
|
||||
$a->strings["You are now authenticated to app.net. "] = "Sei autenticato su app.net";
|
||||
$a->strings["<p>Error fetching token. Please try again.</p>"] = "<p>Errore recuperando il token. Prova di nuovo</p>";
|
||||
$a->strings["return to the connector page"] = "ritorna alla pagina del connettore";
|
||||
$a->strings["Post to app.net"] = "Invia ad app.net";
|
||||
$a->strings["App.net Export"] = "Esporta App.net";
|
||||
$a->strings["Currently connected to: "] = "Al momento connesso con:";
|
||||
$a->strings["Enable App.net Post Plugin"] = "Abilita il plugin di invio ad App.net";
|
||||
$a->strings["Post to App.net by default"] = "Invia sempre ad App.net";
|
||||
$a->strings["Import the remote timeline"] = "Importa la timeline remota";
|
||||
$a->strings["<p>Error fetching user profile. Please clear the configuration and try again.</p>"] = "<p>Errore recuperando il profilo utente. Svuota la configurazione e prova di nuovo.</p>";
|
||||
$a->strings["<p>You have two ways to connect to App.net.</p>"] = "<p>Puoi collegarti ad App.net in due modi.</p>";
|
||||
$a->strings["<p>First way: Register an application at <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. "] = "<p>Registrare un'applicazione su <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> e inserire Client ID e Client Secret.";
|
||||
$a->strings["Use '%s' as Redirect URI<p>"] = "Usa '%s' come Redirect URI</p>";
|
||||
$a->strings["Client ID"] = "Client ID";
|
||||
$a->strings["Client Secret"] = "Client Secret";
|
||||
$a->strings["<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "] = "<p>Oppure puoi recuperare un token su <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>.";
|
||||
$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"] = "Imposta gli ambiti 'Basic', 'Stream', 'Scrivi Post', 'Messaggi Pubblici', 'Messaggi'.</p>";
|
||||
$a->strings["Token"] = "Token";
|
||||
$a->strings["Sign in using App.net"] = "Autenticati con App.net";
|
||||
$a->strings["Clear OAuth configuration"] = "Pulisci configurazione OAuth";
|
||||
$a->strings["Save Settings"] = "Salva Impostazioni";
|
||||
118
appnet/lang/nl/messages.po
Normal file
118
appnet/lang/nl/messages.po
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
# Translators:
|
||||
# Jeroen S <j.soeurt@gmail.com>, 2016
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: 2016-06-23 19:52+0000\n"
|
||||
"Last-Translator: Jeroen S <j.soeurt@gmail.com>\n"
|
||||
"Language-Team: Dutch (http://www.transifex.com/Friendica/friendica/language/nl/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: nl\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr "Toegang geweigerd"
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr "Je bent nu aangemeld bij app.net."
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr "<p>Fout tijdens token fetching. Probeer het nogmaals.</p>"
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr "ga terug naar de connector pagina"
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr "Post naar app.net."
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr "App.net Export"
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr "Momenteel verbonden met:"
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr "App.net Post Plugin inschakelen"
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr "Naar App.net posten als standaard instellen"
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr "The tijdlijn op afstand importeren"
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try "
|
||||
"again.</p>"
|
||||
msgstr "<p>Fout tijdens het ophalen van gebruikersprofiel. Leeg de configuratie en probeer het opnieuw.</p>"
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr "<p>Er zijn twee manieren om met App.net te verbinden.</p>"
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a "
|
||||
"href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a>"
|
||||
" and enter Client ID and Client Secret. "
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-"
|
||||
"lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr ""
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr ""
|
||||
29
appnet/lang/nl/strings.php
Normal file
29
appnet/lang/nl/strings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(! function_exists("string_plural_select_nl")) {
|
||||
function string_plural_select_nl($n){
|
||||
return ($n != 1);;
|
||||
}}
|
||||
;
|
||||
$a->strings["Permission denied."] = "Toegang geweigerd";
|
||||
$a->strings["You are now authenticated to app.net. "] = "Je bent nu aangemeld bij app.net.";
|
||||
$a->strings["<p>Error fetching token. Please try again.</p>"] = "<p>Fout tijdens token fetching. Probeer het nogmaals.</p>";
|
||||
$a->strings["return to the connector page"] = "ga terug naar de connector pagina";
|
||||
$a->strings["Post to app.net"] = "Post naar app.net.";
|
||||
$a->strings["App.net Export"] = "App.net Export";
|
||||
$a->strings["Currently connected to: "] = "Momenteel verbonden met:";
|
||||
$a->strings["Enable App.net Post Plugin"] = "App.net Post Plugin inschakelen";
|
||||
$a->strings["Post to App.net by default"] = "Naar App.net posten als standaard instellen";
|
||||
$a->strings["Import the remote timeline"] = "The tijdlijn op afstand importeren";
|
||||
$a->strings["<p>Error fetching user profile. Please clear the configuration and try again.</p>"] = "<p>Fout tijdens het ophalen van gebruikersprofiel. Leeg de configuratie en probeer het opnieuw.</p>";
|
||||
$a->strings["<p>You have two ways to connect to App.net.</p>"] = "<p>Er zijn twee manieren om met App.net te verbinden.</p>";
|
||||
$a->strings["<p>First way: Register an application at <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. "] = "";
|
||||
$a->strings["Use '%s' as Redirect URI<p>"] = "";
|
||||
$a->strings["Client ID"] = "";
|
||||
$a->strings["Client Secret"] = "";
|
||||
$a->strings["<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "] = "";
|
||||
$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"] = "";
|
||||
$a->strings["Token"] = "";
|
||||
$a->strings["Sign in using App.net"] = "";
|
||||
$a->strings["Clear OAuth configuration"] = "";
|
||||
$a->strings["Save Settings"] = "";
|
||||
119
appnet/lang/pt-br/messages.po
Normal file
119
appnet/lang/pt-br/messages.po
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
# Translators:
|
||||
# Beatriz Vital <vitalb@riseup.net>, 2016
|
||||
# Calango Jr <jcsojr@gmail.com>, 2014
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: 2016-08-19 20:37+0000\n"
|
||||
"Last-Translator: Beatriz Vital <vitalb@riseup.net>\n"
|
||||
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/Friendica/friendica/language/pt_BR/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: pt_BR\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr "Permissão negada."
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr "Você está autenticado no app.net."
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr "Erro ocorrido na obtenção do token. Tente novamente."
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr "Volte a página de conectores."
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr "Publicar no App.net"
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr "App.net exportar"
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr "Atualmente conectado em: "
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr "Habilitar plug-in para publicar no App.net"
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr "Publicar em App.net por padrão"
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr "Importar a linha do tempo remota"
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try "
|
||||
"again.</p>"
|
||||
msgstr "Erro na obtenção do perfil do usuário. Confira as configurações e tente novamente."
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr "<p>Você possui duas formas de conectar ao App.net</p>"
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a "
|
||||
"href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a>"
|
||||
" and enter Client ID and Client Secret. "
|
||||
msgstr "<p>1º Método: Registre uma aplicação em <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> e entre o Client ID e Client Secret"
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr "Use '%s' como URI redirecionador<p>"
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr "Client ID"
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr "Client Secret"
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-"
|
||||
"lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr "<p>2º Método: obtenha um token em <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr "Adicione valor as estas saídas: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr "Token"
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr "Entre usando o App.net"
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr "Limpar configuração OAuth"
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr "Salvar Configurações"
|
||||
29
appnet/lang/pt-br/strings.php
Normal file
29
appnet/lang/pt-br/strings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(! function_exists("string_plural_select_pt_br")) {
|
||||
function string_plural_select_pt_br($n){
|
||||
return ($n > 1);;
|
||||
}}
|
||||
;
|
||||
$a->strings["Permission denied."] = "Permissão negada.";
|
||||
$a->strings["You are now authenticated to app.net. "] = "Você está autenticado no app.net.";
|
||||
$a->strings["<p>Error fetching token. Please try again.</p>"] = "Erro ocorrido na obtenção do token. Tente novamente.";
|
||||
$a->strings["return to the connector page"] = "Volte a página de conectores.";
|
||||
$a->strings["Post to app.net"] = "Publicar no App.net";
|
||||
$a->strings["App.net Export"] = "App.net exportar";
|
||||
$a->strings["Currently connected to: "] = "Atualmente conectado em: ";
|
||||
$a->strings["Enable App.net Post Plugin"] = "Habilitar plug-in para publicar no App.net";
|
||||
$a->strings["Post to App.net by default"] = "Publicar em App.net por padrão";
|
||||
$a->strings["Import the remote timeline"] = "Importar a linha do tempo remota";
|
||||
$a->strings["<p>Error fetching user profile. Please clear the configuration and try again.</p>"] = "Erro na obtenção do perfil do usuário. Confira as configurações e tente novamente.";
|
||||
$a->strings["<p>You have two ways to connect to App.net.</p>"] = "<p>Você possui duas formas de conectar ao App.net</p>";
|
||||
$a->strings["<p>First way: Register an application at <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. "] = "<p>1º Método: Registre uma aplicação em <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> e entre o Client ID e Client Secret";
|
||||
$a->strings["Use '%s' as Redirect URI<p>"] = "Use '%s' como URI redirecionador<p>";
|
||||
$a->strings["Client ID"] = "Client ID";
|
||||
$a->strings["Client Secret"] = "Client Secret";
|
||||
$a->strings["<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "] = "<p>2º Método: obtenha um token em <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. ";
|
||||
$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"] = "Adicione valor as estas saídas: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>";
|
||||
$a->strings["Token"] = "Token";
|
||||
$a->strings["Sign in using App.net"] = "Entre usando o App.net";
|
||||
$a->strings["Clear OAuth configuration"] = "Limpar configuração OAuth";
|
||||
$a->strings["Save Settings"] = "Salvar Configurações";
|
||||
117
appnet/lang/ro/messages.po
Normal file
117
appnet/lang/ro/messages.po
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
# Translators:
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: 2014-07-08 11:40+0000\n"
|
||||
"Last-Translator: Arian - Cazare Muncitori <arianserv@gmail.com>\n"
|
||||
"Language-Team: Romanian (Romania) (http://www.transifex.com/projects/p/friendica/language/ro_RO/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: ro_RO\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr "Permisiune refuzată."
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr "Acum sunteți autentificat pe App.net."
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr "<p>Eroare la procesarea token-ului. Vă rugăm să reîncercați.</p>"
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr "revenire la pagina de conectare"
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr "Postați pe App.net"
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr "Exportare pe App.net"
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr "Conectat curent la:"
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr "Activare Modul Postare pe App.net"
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr "Postați implicit pe App.net"
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr "Importare cronologie la distanță"
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try "
|
||||
"again.</p>"
|
||||
msgstr "<p>Eroare la procesarea profilului de utilizator. Vă rugăm să ștergeți configurarea şi apoi reîncercați.</p>"
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr "<p>Aveți două modalități de a vă conecta la App.net.</p>"
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a "
|
||||
"href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a>"
|
||||
" and enter Client ID and Client Secret. "
|
||||
msgstr "<p>Prima modalitate: Înregistrați o cerere pe <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> şi introduceți ID Client şi Cheia Secretă Client."
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr "Utilizați '%s' ca URI de Redirecţionare<p>"
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr "ID Client"
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr "Cheia Secretă Client"
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-"
|
||||
"lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr "<p>A doua cale: autorizați un indicativ de acces token de pe <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a> ."
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr "Stabiliți aceste scopuri: 'De Bază', 'Flux', 'Scriere Postare', 'Mesaje Publice', 'Mesaje'.</p>"
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr "Token"
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr "Autentificați-vă utilizând App.net"
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr "Ștergeți configurările OAuth"
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr "Salvare Configurări"
|
||||
29
appnet/lang/ro/strings.php
Normal file
29
appnet/lang/ro/strings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(! function_exists("string_plural_select_ro")) {
|
||||
function string_plural_select_ro($n){
|
||||
return ($n==1?0:((($n%100>19)||(($n%100==0)&&($n!=0)))?2:1));;
|
||||
}}
|
||||
;
|
||||
$a->strings["Permission denied."] = "Permisiune refuzată.";
|
||||
$a->strings["You are now authenticated to app.net. "] = "Acum sunteți autentificat pe App.net.";
|
||||
$a->strings["<p>Error fetching token. Please try again.</p>"] = "<p>Eroare la procesarea token-ului. Vă rugăm să reîncercați.</p>";
|
||||
$a->strings["return to the connector page"] = "revenire la pagina de conectare";
|
||||
$a->strings["Post to app.net"] = "Postați pe App.net";
|
||||
$a->strings["App.net Export"] = "Exportare pe App.net";
|
||||
$a->strings["Currently connected to: "] = "Conectat curent la:";
|
||||
$a->strings["Enable App.net Post Plugin"] = "Activare Modul Postare pe App.net";
|
||||
$a->strings["Post to App.net by default"] = "Postați implicit pe App.net";
|
||||
$a->strings["Import the remote timeline"] = "Importare cronologie la distanță";
|
||||
$a->strings["<p>Error fetching user profile. Please clear the configuration and try again.</p>"] = "<p>Eroare la procesarea profilului de utilizator. Vă rugăm să ștergeți configurarea şi apoi reîncercați.</p>";
|
||||
$a->strings["<p>You have two ways to connect to App.net.</p>"] = "<p>Aveți două modalități de a vă conecta la App.net.</p>";
|
||||
$a->strings["<p>First way: Register an application at <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. "] = "<p>Prima modalitate: Înregistrați o cerere pe <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> şi introduceți ID Client şi Cheia Secretă Client.";
|
||||
$a->strings["Use '%s' as Redirect URI<p>"] = "Utilizați '%s' ca URI de Redirecţionare<p>";
|
||||
$a->strings["Client ID"] = "ID Client";
|
||||
$a->strings["Client Secret"] = "Cheia Secretă Client";
|
||||
$a->strings["<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "] = "<p>A doua cale: autorizați un indicativ de acces token de pe <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a> .";
|
||||
$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"] = "Stabiliți aceste scopuri: 'De Bază', 'Flux', 'Scriere Postare', 'Mesaje Publice', 'Mesaje'.</p>";
|
||||
$a->strings["Token"] = "Token";
|
||||
$a->strings["Sign in using App.net"] = "Autentificați-vă utilizând App.net";
|
||||
$a->strings["Clear OAuth configuration"] = "Ștergeți configurările OAuth";
|
||||
$a->strings["Save Settings"] = "Salvare Configurări";
|
||||
118
appnet/lang/ru/messages.po
Normal file
118
appnet/lang/ru/messages.po
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# ADDON appnet
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica appnet addon package.
|
||||
#
|
||||
#
|
||||
# Translators:
|
||||
# Stanislav N. <pztrn@pztrn.name>, 2017
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-06-22 11:47+0200\n"
|
||||
"PO-Revision-Date: 2017-04-08 05:32+0000\n"
|
||||
"Last-Translator: Stanislav N. <pztrn@pztrn.name>\n"
|
||||
"Language-Team: Russian (http://www.transifex.com/Friendica/friendica/language/ru/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: ru\n"
|
||||
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
|
||||
|
||||
#: appnet.php:39
|
||||
msgid "Permission denied."
|
||||
msgstr "Доступ запрещен."
|
||||
|
||||
#: appnet.php:73
|
||||
msgid "You are now authenticated to app.net. "
|
||||
msgstr "Вы аутентифицированы на app.net"
|
||||
|
||||
#: appnet.php:77
|
||||
msgid "<p>Error fetching token. Please try again.</p>"
|
||||
msgstr "<p>Ошибка получения токена. Попробуйте еще раз.</p>"
|
||||
|
||||
#: appnet.php:80
|
||||
msgid "return to the connector page"
|
||||
msgstr "вернуться на страницу коннектора"
|
||||
|
||||
#: appnet.php:94
|
||||
msgid "Post to app.net"
|
||||
msgstr "Отправить на app.net"
|
||||
|
||||
#: appnet.php:125 appnet.php:129
|
||||
msgid "App.net Export"
|
||||
msgstr "Экспорт app.net"
|
||||
|
||||
#: appnet.php:142
|
||||
msgid "Currently connected to: "
|
||||
msgstr "В настоящее время соединены с: "
|
||||
|
||||
#: appnet.php:144
|
||||
msgid "Enable App.net Post Plugin"
|
||||
msgstr "Включить плагин App.net"
|
||||
|
||||
#: appnet.php:149
|
||||
msgid "Post to App.net by default"
|
||||
msgstr "Отправлять сообщения на App.net по-умолчанию"
|
||||
|
||||
#: appnet.php:153
|
||||
msgid "Import the remote timeline"
|
||||
msgstr "Импортировать удаленные сообщения"
|
||||
|
||||
#: appnet.php:159
|
||||
msgid ""
|
||||
"<p>Error fetching user profile. Please clear the configuration and try "
|
||||
"again.</p>"
|
||||
msgstr "<p>Ошибка при получении профиля пользователя. Сбросьте конфигурацию и попробуйте еще раз.</p>"
|
||||
|
||||
#: appnet.php:164
|
||||
msgid "<p>You have two ways to connect to App.net.</p>"
|
||||
msgstr "<p>У вас есть два способа соединения с App.net.</p>"
|
||||
|
||||
#: appnet.php:166
|
||||
msgid ""
|
||||
"<p>First way: Register an application at <a "
|
||||
"href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a>"
|
||||
" and enter Client ID and Client Secret. "
|
||||
msgstr "<p>Первый способ: зарегистрируйте приложение на <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> и введите Client ID и Client Secret"
|
||||
|
||||
#: appnet.php:167
|
||||
#, php-format
|
||||
msgid "Use '%s' as Redirect URI<p>"
|
||||
msgstr "Используйте '%s' как Redirect URI<p>"
|
||||
|
||||
#: appnet.php:169
|
||||
msgid "Client ID"
|
||||
msgstr "Client ID"
|
||||
|
||||
#: appnet.php:173
|
||||
msgid "Client Secret"
|
||||
msgstr "Client Secret"
|
||||
|
||||
#: appnet.php:177
|
||||
msgid ""
|
||||
"<p>Second way: fetch a token at <a href=\"http://dev-"
|
||||
"lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
msgstr "<p>Второй путь: получите токен на <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "
|
||||
|
||||
#: appnet.php:178
|
||||
msgid ""
|
||||
"Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', "
|
||||
"'Messages'.</p>"
|
||||
msgstr "Выберите области: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"
|
||||
|
||||
#: appnet.php:180
|
||||
msgid "Token"
|
||||
msgstr "Токен"
|
||||
|
||||
#: appnet.php:192
|
||||
msgid "Sign in using App.net"
|
||||
msgstr "Войти через App.net"
|
||||
|
||||
#: appnet.php:197
|
||||
msgid "Clear OAuth configuration"
|
||||
msgstr "Удалить конфигурацию OAuth"
|
||||
|
||||
#: appnet.php:204
|
||||
msgid "Save Settings"
|
||||
msgstr "Сохранить настройки"
|
||||
29
appnet/lang/ru/strings.php
Normal file
29
appnet/lang/ru/strings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(! function_exists("string_plural_select_ru")) {
|
||||
function string_plural_select_ru($n){
|
||||
return ($n%10==1 && $n%100!=11 ? 0 : $n%10>=2 && $n%10<=4 && ($n%100<12 || $n%100>14) ? 1 : $n%10==0 || ($n%10>=5 && $n%10<=9) || ($n%100>=11 && $n%100<=14)? 2 : 3);;
|
||||
}}
|
||||
;
|
||||
$a->strings["Permission denied."] = "Доступ запрещен.";
|
||||
$a->strings["You are now authenticated to app.net. "] = "Вы аутентифицированы на app.net";
|
||||
$a->strings["<p>Error fetching token. Please try again.</p>"] = "<p>Ошибка получения токена. Попробуйте еще раз.</p>";
|
||||
$a->strings["return to the connector page"] = "вернуться на страницу коннектора";
|
||||
$a->strings["Post to app.net"] = "Отправить на app.net";
|
||||
$a->strings["App.net Export"] = "Экспорт app.net";
|
||||
$a->strings["Currently connected to: "] = "В настоящее время соединены с: ";
|
||||
$a->strings["Enable App.net Post Plugin"] = "Включить плагин App.net";
|
||||
$a->strings["Post to App.net by default"] = "Отправлять сообщения на App.net по-умолчанию";
|
||||
$a->strings["Import the remote timeline"] = "Импортировать удаленные сообщения";
|
||||
$a->strings["<p>Error fetching user profile. Please clear the configuration and try again.</p>"] = "<p>Ошибка при получении профиля пользователя. Сбросьте конфигурацию и попробуйте еще раз.</p>";
|
||||
$a->strings["<p>You have two ways to connect to App.net.</p>"] = "<p>У вас есть два способа соединения с App.net.</p>";
|
||||
$a->strings["<p>First way: Register an application at <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. "] = "<p>Первый способ: зарегистрируйте приложение на <a href=\"https://account.app.net/developer/apps/\">https://account.app.net/developer/apps/</a> и введите Client ID и Client Secret";
|
||||
$a->strings["Use '%s' as Redirect URI<p>"] = "Используйте '%s' как Redirect URI<p>";
|
||||
$a->strings["Client ID"] = "Client ID";
|
||||
$a->strings["Client Secret"] = "Client Secret";
|
||||
$a->strings["<p>Second way: fetch a token at <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. "] = "<p>Второй путь: получите токен на <a href=\"http://dev-lite.jonathonduerig.com/\">http://dev-lite.jonathonduerig.com/</a>. ";
|
||||
$a->strings["Set these scopes: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>"] = "Выберите области: 'Basic', 'Stream', 'Write Post', 'Public Messages', 'Messages'.</p>";
|
||||
$a->strings["Token"] = "Токен";
|
||||
$a->strings["Sign in using App.net"] = "Войти через App.net";
|
||||
$a->strings["Clear OAuth configuration"] = "Удалить конфигурацию OAuth";
|
||||
$a->strings["Save Settings"] = "Сохранить настройки";
|
||||
1
appnet/lastid.txt
Normal file
1
appnet/lastid.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
36406925
|
||||
514
appnet/sync.php
Normal file
514
appnet/sync.php
Normal file
|
|
@ -0,0 +1,514 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
To-Do:
|
||||
- like empfangen
|
||||
- Links besser auflösen
|
||||
|
||||
Testen:
|
||||
|
||||
*/
|
||||
require_once("boot.php");
|
||||
|
||||
if(@is_null($a)) {
|
||||
$a = new App;
|
||||
}
|
||||
|
||||
@include(".htconfig.php");
|
||||
require_once("dba.php");
|
||||
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
||||
unset($db_host, $db_user, $db_pass, $db_data);
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
//require_once("addon/appnet/appnet.php");
|
||||
|
||||
$uid = 1;
|
||||
appnet_fetchstream($a, $uid);
|
||||
|
||||
function appnet_fetchstream($a, $uid) {
|
||||
require_once("addon/appnet/AppDotNet.php");
|
||||
require_once('include/items.php');
|
||||
|
||||
$token = get_pconfig($uid,'appnet','token');
|
||||
$clientId = get_pconfig($uid,'appnet','clientid');
|
||||
$clientSecret = get_pconfig($uid,'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid));
|
||||
|
||||
if(count($r))
|
||||
$me = $r[0];
|
||||
else {
|
||||
logger("appnet_fetchstream: Own contact not found for user ".$uid, LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
$user = q("SELECT * FROM `user` WHERE `uid` = %d AND `account_expired` = 0 LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if(count($user))
|
||||
$user = $user[0];
|
||||
else {
|
||||
logger("appnet_fetchstream: Own user not found for user ".$uid, LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
$ownid = get_pconfig($uid,'appnet','ownid');
|
||||
|
||||
$param = array("include_annotations" => true);
|
||||
$post = $app->getPost(32189565, $param);
|
||||
//$post = $app->getPost(32166492, $param);
|
||||
//$post = $app->getPost(32166065, $param);
|
||||
//$post = $app->getPost(32161780, $param);
|
||||
$postarray = appnet2_createpost($a, $uid, $post, $me, $user, $ownid, false);
|
||||
print_r($postarray);
|
||||
// $item = item_store($postarray);
|
||||
die();
|
||||
|
||||
|
||||
// Fetch stream
|
||||
$param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true, "include_html" => false, "include_annotations" => true);
|
||||
|
||||
$lastid = get_pconfig($uid, 'appnet', 'laststreamid');
|
||||
|
||||
if ($lastid <> "")
|
||||
$param["since_id"] = $lastid;
|
||||
|
||||
try {
|
||||
$stream = $app->getUserStream($param);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger("appnet_fetchstream: Error fetching stream for user ".$uid);
|
||||
}
|
||||
|
||||
$stream = array_reverse($stream);
|
||||
foreach ($stream AS $post) {
|
||||
$postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, true);
|
||||
|
||||
$item = item_store($postarray);
|
||||
logger('appnet_fetchstream: User '.$uid.' posted stream item '.$item);
|
||||
|
||||
$lastid = $post["id"];
|
||||
|
||||
if (($item != 0) AND ($postarray['contact-id'] != $me["id"])) {
|
||||
$r = q("SELECT `thread`.`iid` AS `parent` FROM `thread`
|
||||
INNER JOIN `item` ON `thread`.`iid` = `item`.`parent` AND `thread`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`id` = %d AND `thread`.`mention` LIMIT 1", dbesc($item));
|
||||
|
||||
if (count($r)) {
|
||||
require_once('include/enotify.php');
|
||||
notification(array(
|
||||
'type' => NOTIFY_COMMENT,
|
||||
'notify_flags' => $user['notify-flags'],
|
||||
'language' => $user['language'],
|
||||
'to_name' => $user['username'],
|
||||
'to_email' => $user['email'],
|
||||
'uid' => $user['uid'],
|
||||
'item' => $postarray,
|
||||
'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item,
|
||||
'source_name' => $postarray['author-name'],
|
||||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_POST,
|
||||
'otype' => 'item',
|
||||
'parent' => $r[0]["parent"],
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set_pconfig($uid, 'appnet', 'laststreamid', $lastid);
|
||||
|
||||
// Fetch mentions
|
||||
$param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true, "include_html" => false, "include_annotations" => true);
|
||||
|
||||
$lastid = get_pconfig($uid, 'appnet', 'lastmentionid');
|
||||
|
||||
if ($lastid <> "")
|
||||
$param["since_id"] = $lastid;
|
||||
|
||||
try {
|
||||
$mentions = $app->getUserMentions("me", $param);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger("appnet_fetchstream: Error fetching mentions for user ".$uid);
|
||||
}
|
||||
|
||||
$mentions = array_reverse($mentions);
|
||||
foreach ($mentions AS $post) {
|
||||
$postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, false);
|
||||
|
||||
if (isset($postarray["id"]))
|
||||
$item = $postarray["id"];
|
||||
elseif (isset($postarray["body"])) {
|
||||
$item = item_store($postarray);
|
||||
logger('appnet_fetchstream: User '.$uid.' posted mention item '.$item);
|
||||
} else
|
||||
$item = 0;
|
||||
|
||||
$lastid = $post["id"];
|
||||
|
||||
if ($item != 0) {
|
||||
require_once('include/enotify.php');
|
||||
notification(array(
|
||||
'type' => NOTIFY_TAGSELF,
|
||||
'notify_flags' => $user['notify-flags'],
|
||||
'language' => $user['language'],
|
||||
'to_name' => $user['username'],
|
||||
'to_email' => $user['email'],
|
||||
'uid' => $user['uid'],
|
||||
'item' => $postarray,
|
||||
'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item,
|
||||
'source_name' => $postarray['author-name'],
|
||||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_TAG,
|
||||
'otype' => 'item'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
set_pconfig($uid, 'appnet', 'lastmentionid', $lastid);
|
||||
|
||||
|
||||
/* To-Do
|
||||
$param = array("interaction_actions" => "star");
|
||||
$interactions = $app->getMyInteractions($param);
|
||||
foreach ($interactions AS $interaction)
|
||||
appnet_dolike($a, $uid, $interaction);
|
||||
*/
|
||||
}
|
||||
|
||||
function appnet2_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $threadcompletion = true) {
|
||||
require_once('include/items.php');
|
||||
|
||||
if ($post["machine_only"])
|
||||
return;
|
||||
|
||||
if ($post["is_deleted"])
|
||||
return;
|
||||
|
||||
$postarray = array();
|
||||
$postarray['gravity'] = 0;
|
||||
$postarray['uid'] = $uid;
|
||||
$postarray['wall'] = 0;
|
||||
$postarray['verb'] = ACTIVITY_POST;
|
||||
$postarray['network'] = dbesc(NETWORK_APPNET);
|
||||
$postarray['uri'] = "adn::".$post["id"];
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
// if (count($r))
|
||||
// return($r[0]);
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['uri']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
// if (count($r))
|
||||
// return($r[0]);
|
||||
|
||||
$postarray['parent-uri'] = "adn::".$post["thread_id"];
|
||||
if (isset($post["reply_to"]) AND ($post["reply_to"] != "")) {
|
||||
$postarray['thr-parent'] = "adn::".$post["reply_to"];
|
||||
|
||||
// Complete the thread if the parent doesn't exists
|
||||
if ($threadcompletion) {
|
||||
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($postarray['thr-parent']),
|
||||
intval($uid)
|
||||
);
|
||||
if (!count($r)) {
|
||||
require_once("addon/appnet/AppDotNet.php");
|
||||
|
||||
$token = get_pconfig($uid,'appnet','token');
|
||||
$clientId = get_pconfig($uid,'appnet','clientid');
|
||||
$clientSecret = get_pconfig($uid,'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
$param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true, "include_html" => false, "include_annotations" => true);
|
||||
try {
|
||||
$thread = $app->getPostReplies($post["thread_id"], $param);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
logger("appnet_createpost: Error fetching thread for user ".$uid);
|
||||
}
|
||||
$thread = array_reverse($thread);
|
||||
foreach ($thread AS $tpost) {
|
||||
$threadpost = appnet2_createpost($a, $uid, $tpost, $me, $user, $ownid, $createuser, false);
|
||||
$item = item_store($threadpost);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
$postarray['thr-parent'] = $postarray['uri'];
|
||||
|
||||
$postarray['plink'] = $post["canonical_url"];
|
||||
|
||||
if ($post["user"]["id"] != $ownid) {
|
||||
$postarray['owner-name'] = $post["user"]["name"];
|
||||
$postarray['owner-link'] = $post["user"]["canonical_url"];
|
||||
$postarray['owner-avatar'] = $post["user"]["avatar_image"]["url"];
|
||||
$postarray['contact-id'] = appnet_fetchcontact($a, $uid, $post["user"], $me, $createuser);
|
||||
} else {
|
||||
$postarray['owner-name'] = $me["name"];
|
||||
$postarray['owner-link'] = $me["url"];
|
||||
$postarray['owner-avatar'] = $me["thumb"];
|
||||
$postarray['contact-id'] = $me["id"];
|
||||
}
|
||||
|
||||
$links = array();
|
||||
|
||||
if (is_array($post["repost_of"])) {
|
||||
$postarray['author-name'] = $post["repost_of"]["user"]["name"];
|
||||
$postarray['author-link'] = $post["repost_of"]["user"]["canonical_url"];
|
||||
$postarray['author-avatar'] = $post["repost_of"]["user"]["avatar_image"]["url"];
|
||||
|
||||
$content = $post["repost_of"];
|
||||
} else {
|
||||
$postarray['author-name'] = $postarray['owner-name'];
|
||||
$postarray['author-link'] = $postarray['owner-link'];
|
||||
$postarray['author-avatar'] = $postarray['owner-avatar'];
|
||||
|
||||
$content = $post;
|
||||
}
|
||||
|
||||
if (is_array($content["entities"])) {
|
||||
$converted = appnet_expand_entities($a, $content["text"], $content["entities"]);
|
||||
$postarray['body'] = $converted["body"];
|
||||
$postarray['tag'] = $converted["tags"];
|
||||
} else
|
||||
$postarray['body'] = $content["text"];
|
||||
|
||||
if (is_array($content["annotations"]))
|
||||
$postarray['body'] = appnet_expand_annotations($a, $postarray['body'], $content["annotations"]);
|
||||
|
||||
if (sizeof($content["entities"]["links"]))
|
||||
foreach($content["entities"]["links"] AS $link) {
|
||||
$url = normalise_link($link["url"]);
|
||||
$links[$url] = $url;
|
||||
}
|
||||
|
||||
if (sizeof($content["annotations"]))
|
||||
foreach($content["annotations"] AS $annotation) {
|
||||
if (isset($annotation["value"]["embeddable_url"])) {
|
||||
$url = normalise_link($annotation["value"]["embeddable_url"]);
|
||||
if (isset($links[$url]))
|
||||
unset($links[$url]);
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($links)) {
|
||||
$link = array_pop($links);
|
||||
$url = "[url=".$link."]".$link."[/url]";
|
||||
|
||||
$removedlink = trim(str_replace($url, "", $postarray['body']));
|
||||
|
||||
if (($removedlink == "") OR strstr($postarray['body'], $removedlink))
|
||||
$postarray['body'] = $removedlink;
|
||||
|
||||
$postarray['body'] .= add_page_info($link);
|
||||
}
|
||||
|
||||
$postarray['created'] = datetime_convert('UTC','UTC',$post["created_at"]);
|
||||
$postarray['edited'] = datetime_convert('UTC','UTC',$post["created_at"]);
|
||||
|
||||
$postarray['app'] = $post["source"]["name"];
|
||||
|
||||
return($postarray);
|
||||
//print_r($postarray);
|
||||
//print_r($post);
|
||||
}
|
||||
|
||||
function appnet_expand_entities($a, $body, $entities) {
|
||||
|
||||
if (!function_exists('substr_unicode')) {
|
||||
function substr_unicode($str, $s, $l = null) {
|
||||
return join("", array_slice(
|
||||
preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY), $s, $l));
|
||||
}
|
||||
}
|
||||
|
||||
$tags_arr = array();
|
||||
$replace = array();
|
||||
|
||||
foreach ($entities["mentions"] AS $mention) {
|
||||
$url = "@[url=https://alpha.app.net/".rawurlencode($mention["name"])."]".$mention["name"]."[/url]";
|
||||
$tags_arr["@".$mention["name"]] = $url;
|
||||
$replace[$mention["pos"]] = array("pos"=> $mention["pos"], "len"=> $mention["len"], "replace"=> $url);
|
||||
}
|
||||
|
||||
foreach ($entities["hashtags"] AS $hashtag) {
|
||||
$url = "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag["name"])."]".$hashtag["name"]."[/url]";
|
||||
$tags_arr["#".$hashtag["name"]] = $url;
|
||||
$replace[$hashtag["pos"]] = array("pos"=> $hashtag["pos"], "len"=> $hashtag["len"], "replace"=> $url);
|
||||
}
|
||||
|
||||
foreach ($entities["links"] AS $links) {
|
||||
$url = "[url=".$links["url"]."]".$links["text"]."[/url]";
|
||||
$replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["len"], "replace"=> $url);
|
||||
}
|
||||
|
||||
|
||||
if (sizeof($replace)) {
|
||||
krsort($replace);
|
||||
foreach ($replace AS $entity) {
|
||||
$pre = substr_unicode($body, 0, $entity["pos"]);
|
||||
$post = substr_unicode($body, $entity["pos"] + $entity["len"]);
|
||||
|
||||
$body = $pre.$entity["replace"].$post;
|
||||
}
|
||||
}
|
||||
|
||||
return(array("body" => $body, "tags" => implode($tags_arr, ",")));
|
||||
}
|
||||
|
||||
function appnet_expand_annotations($a, $body, $annotations) {
|
||||
foreach ($annotations AS $annotation) {
|
||||
if ($annotation["value"]["type"] == "photo") {
|
||||
if (($annotation["value"]["thumbnail_large_url"] != "") AND ($annotation["value"]["url"] != ""))
|
||||
$body .= "\n[url=".$annotation["value"]["url"]."][img]".$annotation["value"]["thumbnail_large_url"]."[/img][/url]";
|
||||
elseif ($annotation["value"]["url"] != "")
|
||||
$body .= "\n[img]".$annotation["value"]["url"]."[/img]";
|
||||
}
|
||||
}
|
||||
return $body;
|
||||
}
|
||||
|
||||
function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) {
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("adn::".$contact["id"]));
|
||||
|
||||
if(!count($r) AND !$create_user)
|
||||
return($me);
|
||||
|
||||
|
||||
if (count($r) AND ($r[0]["readonly"] OR $r[0]["blocked"])) {
|
||||
logger("appnet_fetchcontact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if(!count($r)) {
|
||||
// create contact record
|
||||
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
||||
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
||||
`writable`, `blocked`, `readonly`, `pending` )
|
||||
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
|
||||
intval($uid),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($contact["canonical_url"]),
|
||||
dbesc(normalise_link($contact["canonical_url"])),
|
||||
dbesc($contact["username"]."@app.net"),
|
||||
dbesc("adn::".$contact["id"]),
|
||||
dbesc(''),
|
||||
dbesc("adn::".$contact["id"]),
|
||||
dbesc($contact["name"]),
|
||||
dbesc($contact["username"]),
|
||||
dbesc($contact["avatar_image"]["url"]),
|
||||
dbesc(NETWORK_APPNET),
|
||||
intval(CONTACT_IS_FRIEND),
|
||||
intval(1),
|
||||
intval(1)
|
||||
);
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc("adn::".$contact["id"]),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if(! count($r))
|
||||
return(false);
|
||||
|
||||
$contact_id = $r[0]['id'];
|
||||
|
||||
$g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if($g && intval($g[0]['def_gid'])) {
|
||||
require_once('include/group.php');
|
||||
group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
|
||||
}
|
||||
|
||||
require_once("Photo.php");
|
||||
|
||||
$photos = import_profile_photo($contact["avatar_image"]["url"],$uid,$contact_id);
|
||||
|
||||
q("UPDATE `contact` SET `photo` = '%s',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s'
|
||||
WHERE `id` = %d",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact_id)
|
||||
);
|
||||
|
||||
} else {
|
||||
// update profile photos once every two weeks as we have no notification of when they change.
|
||||
|
||||
//$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false);
|
||||
$update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
|
||||
|
||||
// check that we have all the photos, this has been known to fail on occasion
|
||||
|
||||
if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) {
|
||||
|
||||
logger("appnet_fetchcontact: Updating contact ".$contact["username"], LOGGER_DEBUG);
|
||||
|
||||
require_once("Photo.php");
|
||||
|
||||
$photos = import_profile_photo($contact["avatar_image"]["url"], $uid, $r[0]['id']);
|
||||
|
||||
q("UPDATE `contact` SET `photo` = '%s',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s',
|
||||
`url` = '%s',
|
||||
`nurl` = '%s',
|
||||
`addr` = '%s',
|
||||
`name` = '%s',
|
||||
`nick` = '%s'
|
||||
WHERE `id` = %d",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($contact["canonical_url"]),
|
||||
dbesc(normalise_link($contact["canonical_url"])),
|
||||
dbesc($contact["username"]."@app.net"),
|
||||
dbesc($contact["username"]),
|
||||
dbesc($contact["name"]),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return($r[0]["id"]);
|
||||
}
|
||||
|
||||
// starPost
|
||||
// unstarPost
|
||||
// repost
|
||||
// deleteRepost
|
||||
3
appnet/templates/admin.tpl
Normal file
3
appnet/templates/admin.tpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{{include file="field_input.tpl" field=$clientid}}
|
||||
{{include file="field_input.tpl" field=$clientsecret}}
|
||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
|
||||
256
appnet/test.php
Normal file
256
appnet/test.php
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
To-Do:
|
||||
|
||||
*/
|
||||
require_once("boot.php");
|
||||
|
||||
if(@is_null($a)) {
|
||||
$a = new App;
|
||||
}
|
||||
|
||||
@include(".htconfig.php");
|
||||
require_once("dba.php");
|
||||
dba::connect($db_host, $db_user, $db_pass, $db_data);
|
||||
unset($db_host, $db_user, $db_pass, $db_data);
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
require_once("addon/appnet/appnet.php");
|
||||
require_once("include/plaintext.php");
|
||||
|
||||
$b['uid'] = 1;
|
||||
|
||||
$token = get_pconfig($b['uid'],'appnet','token');
|
||||
|
||||
require_once 'addon/appnet/AppDotNet.php';
|
||||
|
||||
$clientId = get_pconfig($b["uid"],'appnet','clientid');
|
||||
$clientSecret = get_pconfig($b["uid"],'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
//$param = array("include_annotations" => true);
|
||||
//$param = array("include_muted" => true, "include_directed_posts" => true);
|
||||
$param = array("include_muted" => true, "include_deleted" => false, "include_directed_posts" => true,
|
||||
"include_html" => false, "include_post_annotations" => true);
|
||||
|
||||
|
||||
//$param = array("include_post_annotations" => true, "include_muted" => true, "include_directed_posts" => true);
|
||||
//$post = $app->getPost(37154801, $param);
|
||||
$post = $app->getPost(37189594, $param);
|
||||
//$post = $app->getPost(36892980, $param);
|
||||
//$post = $app->getPost(36837961, $param);
|
||||
//$post = $app->getPost(36843534, $param);
|
||||
|
||||
print_r($post);
|
||||
die();
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($b['uid']));
|
||||
|
||||
if(count($r))
|
||||
$me = $r[0];
|
||||
|
||||
$ownid = get_pconfig($b['uid'],'appnet','ownid');
|
||||
|
||||
$user = q("SELECT * FROM `user` WHERE `uid` = %d AND `account_expired` = 0 LIMIT 1",
|
||||
intval($b['uid'])
|
||||
);
|
||||
|
||||
if(count($user))
|
||||
$user = $user[0];
|
||||
|
||||
$test = appnet_createpost($a, $b['uid'], $post, $me, $user, $ownid, true, false, true);
|
||||
|
||||
print_r($test);
|
||||
|
||||
die();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$post = "♲ AdoraBelle (_Adora_Belle_@twitter.com): They are a little tied up... *rofl* @Shysarah2009 @AldiCustCare";
|
||||
|
||||
$post = str_replace($recycle, ">> ", $post);
|
||||
//$post = preg_replace("=".$recycle." (.*) \((.*)@(.*)\)=ism", ">> $1 ($2@$3)", $ppost);
|
||||
//$post = preg_replace("=".$recycle."(.*)=ism", ">> $1", $ppost);
|
||||
|
||||
die($post);
|
||||
*/
|
||||
$b["uid"] = 1;
|
||||
$b["plink"] = "https://pirati.ca/display/heluecht/2834617";
|
||||
//$b["title"] = "Wenn sich Microsoft per Telefon meldet, sollte man stutzig werden.";
|
||||
|
||||
// Image
|
||||
$b["body"] = "Nur ein kleiner Test, bitte ignorieren. (wird sowieso sofort wieder gelöscht)
|
||||
[url=https://lh3.googleusercontent.com/-5J1tGHGvELQ/U2EL_6RuAHI/AAAAAAAAX5U/71dlHNFUjXw/30.04.14%2B-%2B1][img=479x640]https://lh3.googleusercontent.com/-5J1tGHGvELQ/U2EL_6RuAHI/AAAAAAAAX5U/71dlHNFUjXw/w506-h750/30.04.14%2B-%2B1[/img]
|
||||
[/url]";
|
||||
|
||||
/*
|
||||
$b["body"] = "Übrigens: Früher #[url=http://www.dabo.de]war[/url] alles besser.
|
||||
|
||||
[bookmark=https://www.youtube.com/watch?v=-8yF9zqlpR4]SALTATIO MORTIS - Früher war alles besser | Napalm Records[/bookmark]";
|
||||
*/
|
||||
$b["body"] = "Umfrageergebnisse aus der [url=http://www.heise.de]Hölle.[/url] In [url=http://www.heise.de]Deutschland[/url] wäre das Ergebnis sicherlich ähnlich.
|
||||
[class=type-link][bookmark=http://www.zeit.de/gesellschaft/zeitgeschehen/2014-05/oesterreich-studie-fuehrer]Studie: Ein Drittel der Österreicher will einen starken Führer[/bookmark]
|
||||
[img]http://images.zeit.de/politik/ausland/2014-05/oesterreich-umfrage/oesterreich-umfrage-540x304.jpg[/img]
|
||||
[quote]Wahlen? Parlament? Nicht so wichtig, sagen viele Österreicher laut einer Umfrage. Sie wollen einen Führer, der sich um Demokratie nicht kümmern muss.[/quote]
|
||||
[/class]";
|
||||
|
||||
$b['postopts'] = "appnet";
|
||||
/*
|
||||
$b["body"] = "Dies ist ein Testposting, dass wieder gelöscht werden wird.";
|
||||
*/
|
||||
$b["body"] = "\"This is the end ...\"
|
||||
|
||||
[url=https://pirati.ca/photos/heluecht/image/4ccfc897bf2ab350e0fcce93078365f5][img]https://pirati.ca/photo/4ccfc897bf2ab350e0fcce93078365f5-2.jpg[/img][/url]";
|
||||
|
||||
$b["body"] = "[share author='Lukas' profile='https://alpha.app.net/phasenkasper' avatar='https://d2rfichhc2fb9n.cloudfront.net/image/5/1kT9xKMb9JyBVTCBnDHEaHLRUnd7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvZjkvM2EvNjAvZjkzYTYwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0' link='https://alpha.app.net/phasenkasper/post/32422435' posted='2014-06-12 11:42:18']
|
||||
Ich bin immer wieder begeistern wie toll mein Windows läuft. [url=https://photos.app.net/32422435/1]photos.app.net/32422435/1[/url]
|
||||
[img]https://files.app.net/1/1304673/aHwho5GfB2iXEXGGET4V3lOZVUZ5gyfFNI_CChgQ_iHYTs9sooUCIIMa3MPjLx4DHeFm3qCqEyIlo3ucFM2GDgr5SAHhJcXplNPqYGCzBxx4WP0rKxQAY65YE_tgBTaaxR5f6yMM3RzMBV6ooSH0y6zEmF0yRc6EEgn1WFaddqrSRb5XzT8ThiIspzQOy9b6m[/img][/share]";
|
||||
|
||||
$b["body"] = "Ein A380 ist jetzt nicht unbedingt das unwendigste Flugzeug, habe ich das Gefühl.
|
||||
[share author='Javier Salgado' profile='https://plus.google.com/101295635357824725690' avatar='https://lh6.googleusercontent.com/-uE1alnITTco/AAAAAAAAAAI/AAAAAAAAAcc/jXjCG51oQfg/photo.jpg?sz=50' link='https://plus.google.com/101295635357824725690/posts/CjLEs9pSWFV']Unbelievable Airbus A380 vertical Take-off + Amaz…: http://youtu.be/RJxnwF-MPi0
|
||||
[class=type-video][bookmark=http://youtu.be/RJxnwF-MPi0]Unbelievable Airbus A380 vertical Take-off + Amazing Air Show ( HD ) Paris Air show 2013[/bookmark]
|
||||
[/class][/share]";
|
||||
|
||||
/*
|
||||
require_once("include/plaintext.php");
|
||||
|
||||
$post = plaintext($a, $b, 256, false, 6);
|
||||
|
||||
print_r($post);
|
||||
|
||||
die();
|
||||
*/
|
||||
|
||||
/*
|
||||
$url = "https://pirati.ca/photos/heluecht/image/54d898d7e1a8e9ba032a5fa352f51862";
|
||||
|
||||
require_once("mod/parse_url.php");
|
||||
$data = parseurl_getsiteinfo($url, true);
|
||||
|
||||
print_r($data);
|
||||
|
||||
die();
|
||||
*/
|
||||
|
||||
//$id = 3949352;
|
||||
$id = 3949512;
|
||||
$r = q("SELECT * FROM `item` WHERE `id` = %d", intval($id));
|
||||
$b = $r[0];
|
||||
|
||||
$b['postopts'] = "appnet";
|
||||
|
||||
//$data = get_attached_data($b["body"]);
|
||||
//print_r($data);
|
||||
|
||||
$post = plaintext($a, $b, 256, false, 6);
|
||||
|
||||
print_r($post);
|
||||
|
||||
$data = appnet_create_entities($a, $b, $post);
|
||||
|
||||
print_r($data);
|
||||
|
||||
die();
|
||||
|
||||
appnet_send($a, $b);
|
||||
die();
|
||||
|
||||
|
||||
$token = get_pconfig($b['uid'],'appnet','token');
|
||||
|
||||
require_once 'addon/appnet/AppDotNet.php';
|
||||
|
||||
$clientId = get_pconfig($b["uid"],'appnet','clientid');
|
||||
$clientSecret = get_pconfig($b["uid"],'appnet','clientsecret');
|
||||
|
||||
$app = new AppDotNet($clientId, $clientSecret);
|
||||
$app->setAccessToken($token);
|
||||
|
||||
//$param = array("include_annotations" => true);
|
||||
$param = array("include_muted" => true, "include_directed_posts" => true);
|
||||
//$param = array("include_post_annotations" => true, "include_muted" => true, "include_directed_posts" => true);
|
||||
//$post = $app->getPost(32236571, $param);
|
||||
//$post = $app->getPost(32237235, $param);
|
||||
//$post = $app->getPost(32217767, $param);
|
||||
//$post = $app->getPost(32203349, $param);
|
||||
//$post = $app->getPost(32239275, $param);
|
||||
//$post = $app->getPost(32261367, $param);
|
||||
//$post = $app->getPost(32306954, $param);
|
||||
$post = $app->getPost(32926285, $param);
|
||||
|
||||
print_r($post);
|
||||
|
||||
die();
|
||||
|
||||
$lastid = @file_get_contents("addon/appnet/lastid.txt");
|
||||
$clients = @file_get_contents("addon/appnet/clients.txt");
|
||||
$users = @file_get_contents("addon/appnet/users.txt");
|
||||
|
||||
if ($lastid != "")
|
||||
$param["since_id"] = $lastid;
|
||||
|
||||
$posts = $app->getPublicPosts($param);
|
||||
|
||||
foreach ($posts AS $post) {
|
||||
$lastid = $post["id"];
|
||||
|
||||
if ((count($post["entities"]["mentions"]) == 0) AND !strstr($clients, $post["source"]["client_id"]))
|
||||
continue;
|
||||
|
||||
if ((count($post["entities"]["mentions"]) > 0) AND !strstr($clients, $post["source"]["client_id"]))
|
||||
$clients .= $post["source"]["client_id"]." - ".$post["source"]["link"]." - ".$post["source"]["name"]."\n";
|
||||
|
||||
if (!strstr($userss, $post["user"]["canonical_url"]))
|
||||
$users .= $post["user"]["canonical_url"]." - ".$post["user"]["username"]."\n";
|
||||
|
||||
echo $post["source"]["link"]." ".$post["source"]["name"]."\n";
|
||||
echo $post["user"]["username"]."\n";
|
||||
echo $post["text"]."\n";
|
||||
//print_r($post["entities"]["mentions"]);
|
||||
echo $post["id"]."\n";
|
||||
echo "---------------------------------\n";
|
||||
}
|
||||
|
||||
file_put_contents("addon/appnet/lastid.txt", $lastid);
|
||||
file_put_contents("addon/appnet/clients.txt", $clients);
|
||||
file_put_contents("addon/appnet/users.txt", $users);
|
||||
|
||||
/*
|
||||
try {
|
||||
$post = $app->getPost(323069541111, $param);
|
||||
}
|
||||
catch (AppDotNetException $e) {
|
||||
print_r(appnet_error($e->getMessage()));
|
||||
}
|
||||
*/
|
||||
|
||||
//print_r($post);
|
||||
die();
|
||||
|
||||
$data = array();
|
||||
$data["annotations"][] = array(
|
||||
"type" => "net.app.core.crosspost",
|
||||
"value" => array(
|
||||
"canonical_url" => $b["plink"]
|
||||
)
|
||||
);
|
||||
|
||||
$data["annotations"][] = array(
|
||||
"type" => "com.friendica.post",
|
||||
"value" => array(
|
||||
"raw" => $b["body2"]
|
||||
)
|
||||
);
|
||||
|
||||
$ret = $app->createPost($b["body"], $data);
|
||||
|
||||
print_r($ret);
|
||||
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
|
|
@ -0,0 +1,2122 @@
|
|||
<?php
|
||||
/*
|
||||
* http.php
|
||||
*
|
||||
* @(#) $Header: /opt2/ena/metal/http/http.php,v 1.91 2013/07/14 13:21:38 mlemos Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
define('HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR', -1);
|
||||
define('HTTP_CLIENT_ERROR_NO_ERROR', 0);
|
||||
define('HTTP_CLIENT_ERROR_INVALID_SERVER_ADDRESS', 1);
|
||||
define('HTTP_CLIENT_ERROR_CANNOT_CONNECT', 2);
|
||||
define('HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE', 3);
|
||||
define('HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE', 4);
|
||||
define('HTTP_CLIENT_ERROR_PROTOCOL_FAILURE', 5);
|
||||
define('HTTP_CLIENT_ERROR_INVALID_PARAMETERS', 6);
|
||||
|
||||
class http_class
|
||||
{
|
||||
var $host_name="";
|
||||
var $host_port=0;
|
||||
var $proxy_host_name="";
|
||||
var $proxy_host_port=80;
|
||||
var $socks_host_name = '';
|
||||
var $socks_host_port = 1080;
|
||||
var $socks_version = '5';
|
||||
|
||||
var $protocol="http";
|
||||
var $request_method="GET";
|
||||
var $user_agent='httpclient (http://www.phpclasses.org/httpclient $Revision: 1.91 $)';
|
||||
var $accept='';
|
||||
var $authentication_mechanism="";
|
||||
var $user;
|
||||
var $password;
|
||||
var $realm;
|
||||
var $workstation;
|
||||
var $proxy_authentication_mechanism="";
|
||||
var $proxy_user;
|
||||
var $proxy_password;
|
||||
var $proxy_realm;
|
||||
var $proxy_workstation;
|
||||
var $request_uri="";
|
||||
var $request="";
|
||||
var $request_headers=array();
|
||||
var $request_user;
|
||||
var $request_password;
|
||||
var $request_realm;
|
||||
var $request_workstation;
|
||||
var $proxy_request_user;
|
||||
var $proxy_request_password;
|
||||
var $proxy_request_realm;
|
||||
var $proxy_request_workstation;
|
||||
var $request_body="";
|
||||
var $request_arguments=array();
|
||||
var $protocol_version="1.1";
|
||||
var $timeout=0;
|
||||
var $data_timeout=0;
|
||||
var $debug=0;
|
||||
var $log_debug=0;
|
||||
var $debug_response_body=1;
|
||||
var $html_debug=0;
|
||||
var $support_cookies=1;
|
||||
var $cookies=array();
|
||||
var $error="";
|
||||
var $error_code = HTTP_CLIENT_ERROR_NO_ERROR;
|
||||
var $exclude_address="";
|
||||
var $follow_redirect=0;
|
||||
var $redirection_limit=5;
|
||||
var $response_status="";
|
||||
var $response_message="";
|
||||
var $file_buffer_length=8000;
|
||||
var $force_multipart_form_post=0;
|
||||
var $prefer_curl = 0;
|
||||
var $keep_alive = 1;
|
||||
var $sasl_authenticate = 1;
|
||||
|
||||
/* private variables - DO NOT ACCESS */
|
||||
|
||||
var $state="Disconnected";
|
||||
var $use_curl=0;
|
||||
var $connection=0;
|
||||
var $content_length=0;
|
||||
var $response="";
|
||||
var $read_response=0;
|
||||
var $read_length=0;
|
||||
var $request_host="";
|
||||
var $next_token="";
|
||||
var $redirection_level=0;
|
||||
var $chunked=0;
|
||||
var $remaining_chunk=0;
|
||||
var $last_chunk_read=0;
|
||||
var $months=array(
|
||||
"Jan"=>"01",
|
||||
"Feb"=>"02",
|
||||
"Mar"=>"03",
|
||||
"Apr"=>"04",
|
||||
"May"=>"05",
|
||||
"Jun"=>"06",
|
||||
"Jul"=>"07",
|
||||
"Aug"=>"08",
|
||||
"Sep"=>"09",
|
||||
"Oct"=>"10",
|
||||
"Nov"=>"11",
|
||||
"Dec"=>"12");
|
||||
var $session='';
|
||||
var $connection_close=0;
|
||||
var $force_close = 0;
|
||||
var $connected_host = '';
|
||||
var $connected_port = -1;
|
||||
var $connected_ssl = 0;
|
||||
|
||||
/* Private methods - DO NOT CALL */
|
||||
|
||||
Function Tokenize($string,$separator="")
|
||||
{
|
||||
if(!strcmp($separator,""))
|
||||
{
|
||||
$separator=$string;
|
||||
$string=$this->next_token;
|
||||
}
|
||||
for($character=0;$character<strlen($separator);$character++)
|
||||
{
|
||||
if(GetType($position=strpos($string,$separator[$character]))=="integer")
|
||||
$found=(IsSet($found) ? min($found,$position) : $position);
|
||||
}
|
||||
if(IsSet($found))
|
||||
{
|
||||
$this->next_token=substr($string,$found+1);
|
||||
return(substr($string,0,$found));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->next_token="";
|
||||
return($string);
|
||||
}
|
||||
}
|
||||
|
||||
Function CookieEncode($value, $name)
|
||||
{
|
||||
return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value));
|
||||
}
|
||||
|
||||
Function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
|
||||
{
|
||||
$this->error_code = $error_code;
|
||||
return($this->error=$error);
|
||||
}
|
||||
|
||||
Function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
|
||||
{
|
||||
if(IsSet($php_error_message)
|
||||
&& strlen($php_error_message))
|
||||
$error.=": ".$php_error_message;
|
||||
return($this->SetError($error, $error_code));
|
||||
}
|
||||
|
||||
Function SetDataAccessError($error,$check_connection=0)
|
||||
{
|
||||
$this->error=$error;
|
||||
$this->error_code = HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE;
|
||||
if(!$this->use_curl
|
||||
&& function_exists("socket_get_status"))
|
||||
{
|
||||
$status=socket_get_status($this->connection);
|
||||
if($status["timed_out"])
|
||||
$this->error.=": data access time out";
|
||||
elseif($status["eof"])
|
||||
{
|
||||
if($check_connection)
|
||||
$this->error="";
|
||||
else
|
||||
$this->error.=": the server disconnected";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Function OutputDebug($message)
|
||||
{
|
||||
if($this->log_debug)
|
||||
error_log($message);
|
||||
else
|
||||
{
|
||||
$message.="\n";
|
||||
if($this->html_debug)
|
||||
$message=str_replace("\n","<br />\n",HtmlEntities($message));
|
||||
echo $message;
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
Function GetLine()
|
||||
{
|
||||
for($line="";;)
|
||||
{
|
||||
if($this->use_curl)
|
||||
{
|
||||
$eol=strpos($this->response,"\n",$this->read_response);
|
||||
$data=($eol ? substr($this->response,$this->read_response,$eol+1-$this->read_response) : "");
|
||||
$this->read_response+=strlen($data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(feof($this->connection))
|
||||
{
|
||||
$this->SetDataAccessError("reached the end of data while reading from the HTTP server connection");
|
||||
return(0);
|
||||
}
|
||||
$data=fgets($this->connection,100);
|
||||
}
|
||||
if(GetType($data)!="string"
|
||||
|| strlen($data)==0)
|
||||
{
|
||||
$this->SetDataAccessError("it was not possible to read line from the HTTP server");
|
||||
return(0);
|
||||
}
|
||||
$line.=$data;
|
||||
$length=strlen($line);
|
||||
if($length
|
||||
&& !strcmp(substr($line,$length-1,1),"\n"))
|
||||
{
|
||||
$length-=(($length>=2 && !strcmp(substr($line,$length-2,1),"\r")) ? 2 : 1);
|
||||
$line=substr($line,0,$length);
|
||||
if($this->debug)
|
||||
$this->OutputDebug("S $line");
|
||||
return($line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Function PutLine($line)
|
||||
{
|
||||
if($this->debug)
|
||||
$this->OutputDebug("C $line");
|
||||
if(!fputs($this->connection,$line."\r\n"))
|
||||
{
|
||||
$this->SetDataAccessError("it was not possible to send a line to the HTTP server");
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
Function PutData($data)
|
||||
{
|
||||
if(strlen($data))
|
||||
{
|
||||
if($this->debug)
|
||||
$this->OutputDebug('C '.$data);
|
||||
if(!fputs($this->connection,$data))
|
||||
{
|
||||
$this->SetDataAccessError("it was not possible to send data to the HTTP server");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
Function FlushData()
|
||||
{
|
||||
if(!fflush($this->connection))
|
||||
{
|
||||
$this->SetDataAccessError("it was not possible to send data to the HTTP server");
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
Function ReadChunkSize()
|
||||
{
|
||||
if($this->remaining_chunk==0)
|
||||
{
|
||||
$debug=$this->debug;
|
||||
if(!$this->debug_response_body)
|
||||
$this->debug=0;
|
||||
$line=$this->GetLine();
|
||||
$this->debug=$debug;
|
||||
if(GetType($line)!="string")
|
||||
return($this->SetError("could not read chunk start: ".$this->error, $this->error_code));
|
||||
$this->remaining_chunk=hexdec($line);
|
||||
if($this->remaining_chunk == 0)
|
||||
{
|
||||
if(!$this->debug_response_body)
|
||||
$this->debug=0;
|
||||
$line=$this->GetLine();
|
||||
$this->debug=$debug;
|
||||
if(GetType($line)!="string")
|
||||
return($this->SetError("could not read chunk end: ".$this->error, $this->error_code));
|
||||
}
|
||||
}
|
||||
return("");
|
||||
}
|
||||
|
||||
Function ReadBytes($length)
|
||||
{
|
||||
if($this->use_curl)
|
||||
{
|
||||
$bytes=substr($this->response,$this->read_response,min($length,strlen($this->response)-$this->read_response));
|
||||
$this->read_response+=strlen($bytes);
|
||||
if($this->debug
|
||||
&& $this->debug_response_body
|
||||
&& strlen($bytes))
|
||||
$this->OutputDebug("S ".$bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->chunked)
|
||||
{
|
||||
for($bytes="",$remaining=$length;$remaining;)
|
||||
{
|
||||
if(strlen($this->ReadChunkSize()))
|
||||
return("");
|
||||
if($this->remaining_chunk==0)
|
||||
{
|
||||
$this->last_chunk_read=1;
|
||||
break;
|
||||
}
|
||||
$ask=min($this->remaining_chunk,$remaining);
|
||||
$chunk=@fread($this->connection,$ask);
|
||||
$read=strlen($chunk);
|
||||
if($read==0)
|
||||
{
|
||||
$this->SetDataAccessError("it was not possible to read data chunk from the HTTP server");
|
||||
return("");
|
||||
}
|
||||
if($this->debug
|
||||
&& $this->debug_response_body)
|
||||
$this->OutputDebug("S ".$chunk);
|
||||
$bytes.=$chunk;
|
||||
$this->remaining_chunk-=$read;
|
||||
$remaining-=$read;
|
||||
if($this->remaining_chunk==0)
|
||||
{
|
||||
if(feof($this->connection))
|
||||
return($this->SetError("reached the end of data while reading the end of data chunk mark from the HTTP server", HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
|
||||
$data=@fread($this->connection,2);
|
||||
if(strcmp($data,"\r\n"))
|
||||
{
|
||||
$this->SetDataAccessError("it was not possible to read end of data chunk from the HTTP server");
|
||||
return("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bytes=@fread($this->connection,$length);
|
||||
if(strlen($bytes))
|
||||
{
|
||||
if($this->debug
|
||||
&& $this->debug_response_body)
|
||||
$this->OutputDebug("S ".$bytes);
|
||||
}
|
||||
else
|
||||
$this->SetDataAccessError("it was not possible to read data from the HTTP server", $this->connection_close);
|
||||
}
|
||||
}
|
||||
return($bytes);
|
||||
}
|
||||
|
||||
Function EndOfInput()
|
||||
{
|
||||
if($this->use_curl)
|
||||
return($this->read_response>=strlen($this->response));
|
||||
if($this->chunked)
|
||||
return($this->last_chunk_read);
|
||||
if($this->content_length_set)
|
||||
return($this->content_length <= $this->read_length);
|
||||
return(feof($this->connection));
|
||||
}
|
||||
|
||||
Function Resolve($domain, &$ip, $server_type)
|
||||
{
|
||||
if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/',$domain))
|
||||
$ip=$domain;
|
||||
else
|
||||
{
|
||||
if($this->debug)
|
||||
$this->OutputDebug('Resolving '.$server_type.' server domain "'.$domain.'"...');
|
||||
if(!strcmp($ip=@gethostbyname($domain),$domain))
|
||||
$ip="";
|
||||
}
|
||||
if(strlen($ip)==0
|
||||
|| (strlen($this->exclude_address)
|
||||
&& !strcmp(@gethostbyname($this->exclude_address),$ip)))
|
||||
return($this->SetError("could not resolve the host domain \"".$domain."\"", HTTP_CLIENT_ERROR_INVALID_SERVER_ADDRESS));
|
||||
return('');
|
||||
}
|
||||
|
||||
Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
|
||||
{
|
||||
$domain=$host_name;
|
||||
$port = $host_port;
|
||||
if(strlen($error = $this->Resolve($domain, $ip, $server_type)))
|
||||
return($error);
|
||||
if(strlen($this->socks_host_name))
|
||||
{
|
||||
switch($this->socks_version)
|
||||
{
|
||||
case '4':
|
||||
$version = 4;
|
||||
break;
|
||||
case '5':
|
||||
$version = 5;
|
||||
break;
|
||||
default:
|
||||
return('it was not specified a supported SOCKS protocol version');
|
||||
break;
|
||||
}
|
||||
$host_ip = $ip;
|
||||
$port = $this->socks_host_port;
|
||||
$host_server_type = $server_type;
|
||||
$server_type = 'SOCKS';
|
||||
if(strlen($error = $this->Resolve($this->socks_host_name, $ip, $server_type)))
|
||||
return($error);
|
||||
}
|
||||
if($this->debug)
|
||||
$this->OutputDebug('Connecting to '.$server_type.' server IP '.$ip.' port '.$port.'...');
|
||||
if($ssl)
|
||||
$ip="ssl://".$host_name;
|
||||
if(($this->connection=($this->timeout ? @fsockopen($ip, $port, $errno, $error, $this->timeout) : @fsockopen($ip, $port, $errno)))==0)
|
||||
{
|
||||
$error_code = HTTP_CLIENT_ERROR_CANNOT_CONNECT;
|
||||
switch($errno)
|
||||
{
|
||||
case -3:
|
||||
return($this->SetError("socket could not be created", $error_code));
|
||||
case -4:
|
||||
return($this->SetError("dns lookup on hostname \"".$host_name."\" failed", $error_code));
|
||||
case -5:
|
||||
return($this->SetError("connection refused or timed out", $error_code));
|
||||
case -6:
|
||||
return($this->SetError("fdopen() call failed", $error_code));
|
||||
case -7:
|
||||
return($this->SetError("setvbuf() call failed", $error_code));
|
||||
default:
|
||||
return($this->SetPHPError($errno." could not connect to the host \"".$host_name."\"",$php_errormsg, $error_code));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->data_timeout
|
||||
&& function_exists("socket_set_timeout"))
|
||||
socket_set_timeout($this->connection,$this->data_timeout,0);
|
||||
if(strlen($this->socks_host_name))
|
||||
{
|
||||
if($this->debug)
|
||||
$this->OutputDebug('Connected to the SOCKS server '.$this->socks_host_name);
|
||||
$send_error = 'it was not possible to send data to the SOCKS server';
|
||||
$receive_error = 'it was not possible to receive data from the SOCKS server';
|
||||
switch($version)
|
||||
{
|
||||
case 4:
|
||||
$command = 1;
|
||||
$user = '';
|
||||
if(!fputs($this->connection, chr($version).chr($command).pack('nN', $host_port, ip2long($host_ip)).$user.Chr(0)))
|
||||
$error = $this->SetDataAccessError($send_error);
|
||||
else
|
||||
{
|
||||
$response = fgets($this->connection, 9);
|
||||
if(strlen($response) != 8)
|
||||
$error = $this->SetDataAccessError($receive_error);
|
||||
else
|
||||
{
|
||||
$socks_errors = array(
|
||||
"\x5a"=>'',
|
||||
"\x5b"=>'request rejected',
|
||||
"\x5c"=>'request failed because client is not running identd (or not reachable from the server)',
|
||||
"\x5d"=>'request failed because client\'s identd could not confirm the user ID string in the request',
|
||||
);
|
||||
$error_code = $response[1];
|
||||
$error = (IsSet($socks_errors[$error_code]) ? $socks_errors[$error_code] : 'unknown');
|
||||
if(strlen($error))
|
||||
$error = 'SOCKS error: '.$error;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if($this->debug)
|
||||
$this->OutputDebug('Negotiating the authentication method ...');
|
||||
$methods = 1;
|
||||
$method = 0;
|
||||
if(!fputs($this->connection, chr($version).chr($methods).chr($method)))
|
||||
$error = $this->SetDataAccessError($send_error);
|
||||
else
|
||||
{
|
||||
$response = fgets($this->connection, 3);
|
||||
if(strlen($response) != 2)
|
||||
$error = $this->SetDataAccessError($receive_error);
|
||||
elseif(Ord($response[1]) != $method)
|
||||
$error = 'the SOCKS server requires an authentication method that is not yet supported';
|
||||
else
|
||||
{
|
||||
if($this->debug)
|
||||
$this->OutputDebug('Connecting to '.$host_server_type.' server IP '.$host_ip.' port '.$host_port.'...');
|
||||
$command = 1;
|
||||
$address_type = 1;
|
||||
if(!fputs($this->connection, chr($version).chr($command)."\x00".chr($address_type).pack('Nn', ip2long($host_ip), $host_port)))
|
||||
$error = $this->SetDataAccessError($send_error);
|
||||
else
|
||||
{
|
||||
$response = fgets($this->connection, 11);
|
||||
if(strlen($response) != 10)
|
||||
$error = $this->SetDataAccessError($receive_error);
|
||||
else
|
||||
{
|
||||
$socks_errors = array(
|
||||
"\x00"=>'',
|
||||
"\x01"=>'general SOCKS server failure',
|
||||
"\x02"=>'connection not allowed by ruleset',
|
||||
"\x03"=>'Network unreachable',
|
||||
"\x04"=>'Host unreachable',
|
||||
"\x05"=>'Connection refused',
|
||||
"\x06"=>'TTL expired',
|
||||
"\x07"=>'Command not supported',
|
||||
"\x08"=>'Address type not supported'
|
||||
);
|
||||
$error_code = $response[1];
|
||||
$error = (IsSet($socks_errors[$error_code]) ? $socks_errors[$error_code] : 'unknown');
|
||||
if(strlen($error))
|
||||
$error = 'SOCKS error: '.$error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$error = 'support for SOCKS protocol version '.$this->socks_version.' is not yet implemented';
|
||||
break;
|
||||
}
|
||||
if(strlen($error))
|
||||
{
|
||||
fclose($this->connection);
|
||||
return($error);
|
||||
}
|
||||
}
|
||||
if($this->debug)
|
||||
$this->OutputDebug("Connected to $host_name");
|
||||
if(strlen($this->proxy_host_name)
|
||||
&& !strcmp(strtolower($this->protocol), 'https'))
|
||||
{
|
||||
if(function_exists('stream_socket_enable_crypto')
|
||||
&& in_array('ssl', stream_get_transports()))
|
||||
$this->state = "ConnectedToProxy";
|
||||
else
|
||||
{
|
||||
$this->OutputDebug("It is not possible to start SSL after connecting to the proxy server. If the proxy refuses to forward the SSL request, you may need to upgrade to PHP 5.1 or later with OpenSSL support enabled.");
|
||||
$this->state="Connected";
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->state="Connected";
|
||||
return("");
|
||||
}
|
||||
}
|
||||
|
||||
Function Disconnect()
|
||||
{
|
||||
if($this->debug)
|
||||
$this->OutputDebug("Disconnected from ".$this->connected_host);
|
||||
if($this->use_curl)
|
||||
{
|
||||
curl_close($this->connection);
|
||||
$this->response="";
|
||||
}
|
||||
else
|
||||
fclose($this->connection);
|
||||
$this->state="Disconnected";
|
||||
return("");
|
||||
}
|
||||
|
||||
/* Public methods */
|
||||
|
||||
Function GetRequestArguments($url, &$arguments)
|
||||
{
|
||||
$this->error = '';
|
||||
$this->error_code = HTTP_CLIENT_ERROR_NO_ERROR;
|
||||
$arguments=array();
|
||||
$url = str_replace(' ', '%20', $url);
|
||||
$parameters=@parse_url($url);
|
||||
if(!$parameters)
|
||||
return($this->SetError("it was not specified a valid URL", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
if(!IsSet($parameters["scheme"]))
|
||||
return($this->SetError("it was not specified the protocol type argument", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
switch(strtolower($parameters["scheme"]))
|
||||
{
|
||||
case "http":
|
||||
case "https":
|
||||
$arguments["Protocol"]=$parameters["scheme"];
|
||||
break;
|
||||
default:
|
||||
return($parameters["scheme"]." connection scheme is not yet supported");
|
||||
}
|
||||
if(!IsSet($parameters["host"]))
|
||||
return($this->SetError("it was not specified the connection host argument", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
$arguments["HostName"]=$parameters["host"];
|
||||
$arguments["Headers"]=array("Host"=>$parameters["host"].(IsSet($parameters["port"]) ? ":".$parameters["port"] : ""));
|
||||
if(IsSet($parameters["user"]))
|
||||
{
|
||||
$arguments["AuthUser"]=UrlDecode($parameters["user"]);
|
||||
if(!IsSet($parameters["pass"]))
|
||||
$arguments["AuthPassword"]="";
|
||||
}
|
||||
if(IsSet($parameters["pass"]))
|
||||
{
|
||||
if(!IsSet($parameters["user"]))
|
||||
$arguments["AuthUser"]="";
|
||||
$arguments["AuthPassword"]=UrlDecode($parameters["pass"]);
|
||||
}
|
||||
if(IsSet($parameters["port"]))
|
||||
{
|
||||
if(strcmp($parameters["port"],strval(intval($parameters["port"]))))
|
||||
return($this->SetError("it was not specified a valid connection host argument", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
$arguments["HostPort"]=intval($parameters["port"]);
|
||||
}
|
||||
else
|
||||
$arguments["HostPort"]=0;
|
||||
$arguments["RequestURI"]=(IsSet($parameters["path"]) ? $parameters["path"] : "/").(IsSet($parameters["query"]) ? "?".$parameters["query"] : "");
|
||||
if(strlen($this->user_agent))
|
||||
$arguments["Headers"]["User-Agent"]=$this->user_agent;
|
||||
if(strlen($this->accept))
|
||||
$arguments["Headers"]["Accept"]=$this->accept;
|
||||
return("");
|
||||
}
|
||||
|
||||
Function Open($arguments)
|
||||
{
|
||||
if(strlen($this->error))
|
||||
return($this->error);
|
||||
$error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR;
|
||||
if(IsSet($arguments["HostName"]))
|
||||
$this->host_name=$arguments["HostName"];
|
||||
if(IsSet($arguments["HostPort"]))
|
||||
$this->host_port=$arguments["HostPort"];
|
||||
if(IsSet($arguments["ProxyHostName"]))
|
||||
$this->proxy_host_name=$arguments["ProxyHostName"];
|
||||
if(IsSet($arguments["ProxyHostPort"]))
|
||||
$this->proxy_host_port=$arguments["ProxyHostPort"];
|
||||
if(IsSet($arguments["SOCKSHostName"]))
|
||||
$this->socks_host_name=$arguments["SOCKSHostName"];
|
||||
if(IsSet($arguments["SOCKSHostPort"]))
|
||||
$this->socks_host_port=$arguments["SOCKSHostPort"];
|
||||
if(IsSet($arguments["SOCKSVersion"]))
|
||||
$this->socks_version=$arguments["SOCKSVersion"];
|
||||
if(IsSet($arguments["Protocol"]))
|
||||
$this->protocol=$arguments["Protocol"];
|
||||
switch(strtolower($this->protocol))
|
||||
{
|
||||
case "http":
|
||||
$default_port=80;
|
||||
break;
|
||||
case "https":
|
||||
$default_port=443;
|
||||
break;
|
||||
default:
|
||||
return($this->SetError("it was not specified a valid connection protocol", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
}
|
||||
if(strlen($this->proxy_host_name)==0)
|
||||
{
|
||||
if(strlen($this->host_name)==0)
|
||||
return($this->SetError("it was not specified a valid hostname", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
$host_name=$this->host_name;
|
||||
$host_port=($this->host_port ? $this->host_port : $default_port);
|
||||
$server_type = 'HTTP';
|
||||
}
|
||||
else
|
||||
{
|
||||
$host_name=$this->proxy_host_name;
|
||||
$host_port=$this->proxy_host_port;
|
||||
$server_type = 'HTTP proxy';
|
||||
}
|
||||
$ssl=(strtolower($this->protocol)=="https" && strlen($this->proxy_host_name)==0);
|
||||
if($ssl
|
||||
&& strlen($this->socks_host_name))
|
||||
return($this->SetError('establishing SSL connections via a SOCKS server is not yet supported', HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
$this->use_curl=($ssl && $this->prefer_curl && function_exists("curl_init"));
|
||||
switch($this->state)
|
||||
{
|
||||
case 'Connected':
|
||||
if(!strcmp($host_name, $this->connected_host)
|
||||
&& intval($host_port) == $this->connected_port
|
||||
&& intval($ssl) == $this->connected_ssl)
|
||||
{
|
||||
if($this->debug)
|
||||
$this->OutputDebug("Reusing connection to ".$this->connected_host);
|
||||
return('');
|
||||
}
|
||||
if(strlen($error = $this->Disconnect()))
|
||||
return($error);
|
||||
case "Disconnected":
|
||||
break;
|
||||
default:
|
||||
return("1 already connected");
|
||||
}
|
||||
if($this->debug)
|
||||
$this->OutputDebug("Connecting to ".$this->host_name);
|
||||
if($this->use_curl)
|
||||
{
|
||||
$error=(($this->connection=curl_init($this->protocol."://".$this->host_name.($host_port==$default_port ? "" : ":".strval($host_port))."/")) ? "" : "Could not initialize a CURL session");
|
||||
if(strlen($error)==0)
|
||||
{
|
||||
if(IsSet($arguments["SSLCertificateFile"]))
|
||||
curl_setopt($this->connection,CURLOPT_SSLCERT,$arguments["SSLCertificateFile"]);
|
||||
if(IsSet($arguments["SSLCertificatePassword"]))
|
||||
curl_setopt($this->connection,CURLOPT_SSLCERTPASSWD,$arguments["SSLCertificatePassword"]);
|
||||
if(IsSet($arguments["SSLKeyFile"]))
|
||||
curl_setopt($this->connection,CURLOPT_SSLKEY,$arguments["SSLKeyFile"]);
|
||||
if(IsSet($arguments["SSLKeyPassword"]))
|
||||
curl_setopt($this->connection,CURLOPT_SSLKEYPASSWD,$arguments["SSLKeyPassword"]);
|
||||
}
|
||||
$this->state="Connected";
|
||||
}
|
||||
else
|
||||
{
|
||||
$error="";
|
||||
if(strlen($this->proxy_host_name)
|
||||
&& (IsSet($arguments["SSLCertificateFile"])
|
||||
|| IsSet($arguments["SSLCertificateFile"])))
|
||||
$error="establishing SSL connections using certificates or private keys via non-SSL proxies is not supported";
|
||||
else
|
||||
{
|
||||
if($ssl)
|
||||
{
|
||||
if(IsSet($arguments["SSLCertificateFile"]))
|
||||
$error="establishing SSL connections using certificates is only supported when the cURL extension is enabled";
|
||||
elseif(IsSet($arguments["SSLKeyFile"]))
|
||||
$error="establishing SSL connections using a private key is only supported when the cURL extension is enabled";
|
||||
else
|
||||
{
|
||||
$version=explode(".",function_exists("phpversion") ? phpversion() : "3.0.7");
|
||||
$php_version=intval($version[0])*1000000+intval($version[1])*1000+intval($version[2]);
|
||||
if($php_version<4003000)
|
||||
$error="establishing SSL connections requires at least PHP version 4.3.0 or having the cURL extension enabled";
|
||||
elseif(!function_exists("extension_loaded")
|
||||
|| !extension_loaded("openssl"))
|
||||
$error="establishing SSL connections requires the OpenSSL extension enabled";
|
||||
}
|
||||
}
|
||||
if(strlen($error)==0)
|
||||
{
|
||||
$error=$this->Connect($host_name, $host_port, $ssl, $server_type);
|
||||
$error_code = $this->error_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(strlen($error))
|
||||
return($this->SetError($error, $error_code));
|
||||
$this->session=md5(uniqid(""));
|
||||
$this->connected_host = $host_name;
|
||||
$this->connected_port = intval($host_port);
|
||||
$this->connected_ssl = intval($ssl);
|
||||
return("");
|
||||
}
|
||||
|
||||
Function Close($force = 0)
|
||||
{
|
||||
if($this->state=="Disconnected")
|
||||
return("1 already disconnected");
|
||||
if(!$this->force_close
|
||||
&& $this->keep_alive
|
||||
&& !$force
|
||||
&& $this->state == 'ResponseReceived')
|
||||
{
|
||||
if($this->debug)
|
||||
$this->OutputDebug('Keeping the connection alive to '.$this->connected_host);
|
||||
$this->state = 'Connected';
|
||||
return('');
|
||||
}
|
||||
return($this->Disconnect());
|
||||
}
|
||||
|
||||
Function PickCookies(&$cookies,$secure)
|
||||
{
|
||||
if(IsSet($this->cookies[$secure]))
|
||||
{
|
||||
$now=gmdate("Y-m-d H-i-s");
|
||||
for($domain=0,Reset($this->cookies[$secure]);$domain<count($this->cookies[$secure]);Next($this->cookies[$secure]),$domain++)
|
||||
{
|
||||
$domain_pattern=Key($this->cookies[$secure]);
|
||||
$match=strlen($this->request_host)-strlen($domain_pattern);
|
||||
if($match>=0
|
||||
&& !strcmp($domain_pattern,substr($this->request_host,$match))
|
||||
&& ($match==0
|
||||
|| $domain_pattern[0]=="."
|
||||
|| $this->request_host[$match-1]=="."))
|
||||
{
|
||||
for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_part<count($this->cookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++)
|
||||
{
|
||||
$path=Key($this->cookies[$secure][$domain_pattern]);
|
||||
if(strlen($this->request_uri)>=strlen($path)
|
||||
&& substr($this->request_uri,0,strlen($path))==$path)
|
||||
{
|
||||
for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookie<count($this->cookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++)
|
||||
{
|
||||
$cookie_name=Key($this->cookies[$secure][$domain_pattern][$path]);
|
||||
$expires=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"];
|
||||
if($expires==""
|
||||
|| strcmp($now,$expires)<0)
|
||||
$cookies[$cookie_name]=$this->cookies[$secure][$domain_pattern][$path][$cookie_name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Function GetFileDefinition($file, &$definition)
|
||||
{
|
||||
$name="";
|
||||
if(IsSet($file["FileName"]))
|
||||
$name=basename($file["FileName"]);
|
||||
if(IsSet($file["Name"]))
|
||||
$name=$file["Name"];
|
||||
if(strlen($name)==0)
|
||||
return("it was not specified the file part name");
|
||||
if(IsSet($file["Content-Type"]))
|
||||
{
|
||||
$content_type=$file["Content-Type"];
|
||||
$type=$this->Tokenize(strtolower($content_type),"/");
|
||||
$sub_type=$this->Tokenize("");
|
||||
switch($type)
|
||||
{
|
||||
case "text":
|
||||
case "image":
|
||||
case "audio":
|
||||
case "video":
|
||||
case "application":
|
||||
case "message":
|
||||
break;
|
||||
case "automatic":
|
||||
switch($sub_type)
|
||||
{
|
||||
case "name":
|
||||
switch(GetType($dot=strrpos($name,"."))=="integer" ? strtolower(substr($name,$dot)) : "")
|
||||
{
|
||||
case ".xls":
|
||||
$content_type="application/excel";
|
||||
break;
|
||||
case ".hqx":
|
||||
$content_type="application/macbinhex40";
|
||||
break;
|
||||
case ".doc":
|
||||
case ".dot":
|
||||
case ".wrd":
|
||||
$content_type="application/msword";
|
||||
break;
|
||||
case ".pdf":
|
||||
$content_type="application/pdf";
|
||||
break;
|
||||
case ".pgp":
|
||||
$content_type="application/pgp";
|
||||
break;
|
||||
case ".ps":
|
||||
case ".eps":
|
||||
case ".ai":
|
||||
$content_type="application/postscript";
|
||||
break;
|
||||
case ".ppt":
|
||||
$content_type="application/powerpoint";
|
||||
break;
|
||||
case ".rtf":
|
||||
$content_type="application/rtf";
|
||||
break;
|
||||
case ".tgz":
|
||||
case ".gtar":
|
||||
$content_type="application/x-gtar";
|
||||
break;
|
||||
case ".gz":
|
||||
$content_type="application/x-gzip";
|
||||
break;
|
||||
case ".php":
|
||||
case ".php3":
|
||||
$content_type="application/x-httpd-php";
|
||||
break;
|
||||
case ".js":
|
||||
$content_type="application/x-javascript";
|
||||
break;
|
||||
case ".ppd":
|
||||
case ".psd":
|
||||
$content_type="application/x-photoshop";
|
||||
break;
|
||||
case ".swf":
|
||||
case ".swc":
|
||||
case ".rf":
|
||||
$content_type="application/x-shockwave-flash";
|
||||
break;
|
||||
case ".tar":
|
||||
$content_type="application/x-tar";
|
||||
break;
|
||||
case ".zip":
|
||||
$content_type="application/zip";
|
||||
break;
|
||||
case ".mid":
|
||||
case ".midi":
|
||||
case ".kar":
|
||||
$content_type="audio/midi";
|
||||
break;
|
||||
case ".mp2":
|
||||
case ".mp3":
|
||||
case ".mpga":
|
||||
$content_type="audio/mpeg";
|
||||
break;
|
||||
case ".ra":
|
||||
$content_type="audio/x-realaudio";
|
||||
break;
|
||||
case ".wav":
|
||||
$content_type="audio/wav";
|
||||
break;
|
||||
case ".bmp":
|
||||
$content_type="image/bitmap";
|
||||
break;
|
||||
case ".gif":
|
||||
$content_type="image/gif";
|
||||
break;
|
||||
case ".iff":
|
||||
$content_type="image/iff";
|
||||
break;
|
||||
case ".jb2":
|
||||
$content_type="image/jb2";
|
||||
break;
|
||||
case ".jpg":
|
||||
case ".jpe":
|
||||
case ".jpeg":
|
||||
$content_type="image/jpeg";
|
||||
break;
|
||||
case ".jpx":
|
||||
$content_type="image/jpx";
|
||||
break;
|
||||
case ".png":
|
||||
$content_type="image/png";
|
||||
break;
|
||||
case ".tif":
|
||||
case ".tiff":
|
||||
$content_type="image/tiff";
|
||||
break;
|
||||
case ".wbmp":
|
||||
$content_type="image/vnd.wap.wbmp";
|
||||
break;
|
||||
case ".xbm":
|
||||
$content_type="image/xbm";
|
||||
break;
|
||||
case ".css":
|
||||
$content_type="text/css";
|
||||
break;
|
||||
case ".txt":
|
||||
$content_type="text/plain";
|
||||
break;
|
||||
case ".htm":
|
||||
case ".html":
|
||||
$content_type="text/html";
|
||||
break;
|
||||
case ".xml":
|
||||
$content_type="text/xml";
|
||||
break;
|
||||
case ".mpg":
|
||||
case ".mpe":
|
||||
case ".mpeg":
|
||||
$content_type="video/mpeg";
|
||||
break;
|
||||
case ".qt":
|
||||
case ".mov":
|
||||
$content_type="video/quicktime";
|
||||
break;
|
||||
case ".avi":
|
||||
$content_type="video/x-ms-video";
|
||||
break;
|
||||
case ".eml":
|
||||
$content_type="message/rfc822";
|
||||
break;
|
||||
default:
|
||||
$content_type="application/octet-stream";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return($content_type." is not a supported automatic content type detection method");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return($content_type." is not a supported file content type");
|
||||
}
|
||||
}
|
||||
else
|
||||
$content_type="application/octet-stream";
|
||||
$definition=array(
|
||||
"Content-Type"=>$content_type,
|
||||
"NAME"=>$name
|
||||
);
|
||||
if(IsSet($file["FileName"]))
|
||||
{
|
||||
if(GetType($length=@filesize($file["FileName"]))!="integer")
|
||||
{
|
||||
$error="it was not possible to determine the length of the file ".$file["FileName"];
|
||||
if(IsSet($php_errormsg)
|
||||
&& strlen($php_errormsg))
|
||||
$error.=": ".$php_errormsg;
|
||||
if(!file_exists($file["FileName"]))
|
||||
$error="it was not possible to access the file ".$file["FileName"];
|
||||
return($error);
|
||||
}
|
||||
$definition["FILENAME"]=$file["FileName"];
|
||||
$definition["Content-Length"]=$length;
|
||||
}
|
||||
elseif(IsSet($file["Data"]))
|
||||
$definition["Content-Length"]=strlen($definition["DATA"]=$file["Data"]);
|
||||
else
|
||||
return("it was not specified a valid file name");
|
||||
return("");
|
||||
}
|
||||
|
||||
Function ConnectFromProxy($arguments, &$headers)
|
||||
{
|
||||
if(!$this->PutLine('CONNECT '.$this->host_name.':'.($this->host_port ? $this->host_port : 443).' HTTP/1.0')
|
||||
|| (strlen($this->user_agent)
|
||||
&& !$this->PutLine('User-Agent: '.$this->user_agent))
|
||||
|| (strlen($this->accept)
|
||||
&& !$this->PutLine('Accept: '.$this->accept))
|
||||
|| (IsSet($arguments['Headers']['Proxy-Authorization'])
|
||||
&& !$this->PutLine('Proxy-Authorization: '.$arguments['Headers']['Proxy-Authorization']))
|
||||
|| !$this->PutLine(''))
|
||||
{
|
||||
$this->Disconnect();
|
||||
return($this->error);
|
||||
}
|
||||
$this->state = "ConnectSent";
|
||||
if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
|
||||
return($error);
|
||||
$proxy_authorization="";
|
||||
while(!strcmp($this->response_status, "100"))
|
||||
{
|
||||
$this->state="ConnectSent";
|
||||
if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
|
||||
return($error);
|
||||
}
|
||||
switch($this->response_status)
|
||||
{
|
||||
case "200":
|
||||
if(!@stream_socket_enable_crypto($this->connection, 1, STREAM_CRYPTO_METHOD_SSLv23_CLIENT))
|
||||
{
|
||||
$this->SetPHPError('it was not possible to start a SSL encrypted connection via this proxy', $php_errormsg, HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE);
|
||||
$this->Disconnect();
|
||||
return($this->error);
|
||||
}
|
||||
$this->state = "Connected";
|
||||
break;
|
||||
case "407":
|
||||
if(strlen($error=$this->Authenticate($headers, -1, $proxy_authorization, $this->proxy_request_user, $this->proxy_request_password, $this->proxy_request_realm, $this->proxy_request_workstation)))
|
||||
return($error);
|
||||
break;
|
||||
default:
|
||||
return($this->SetError("unable to send request via proxy", HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
|
||||
}
|
||||
return("");
|
||||
}
|
||||
|
||||
Function SendRequest($arguments)
|
||||
{
|
||||
if(strlen($this->error))
|
||||
return($this->error);
|
||||
if(IsSet($arguments["ProxyUser"]))
|
||||
$this->proxy_request_user=$arguments["ProxyUser"];
|
||||
elseif(IsSet($this->proxy_user))
|
||||
$this->proxy_request_user=$this->proxy_user;
|
||||
if(IsSet($arguments["ProxyPassword"]))
|
||||
$this->proxy_request_password=$arguments["ProxyPassword"];
|
||||
elseif(IsSet($this->proxy_password))
|
||||
$this->proxy_request_password=$this->proxy_password;
|
||||
if(IsSet($arguments["ProxyRealm"]))
|
||||
$this->proxy_request_realm=$arguments["ProxyRealm"];
|
||||
elseif(IsSet($this->proxy_realm))
|
||||
$this->proxy_request_realm=$this->proxy_realm;
|
||||
if(IsSet($arguments["ProxyWorkstation"]))
|
||||
$this->proxy_request_workstation=$arguments["ProxyWorkstation"];
|
||||
elseif(IsSet($this->proxy_workstation))
|
||||
$this->proxy_request_workstation=$this->proxy_workstation;
|
||||
switch($this->state)
|
||||
{
|
||||
case "Disconnected":
|
||||
return($this->SetError("connection was not yet established", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
case "Connected":
|
||||
$connect = 0;
|
||||
break;
|
||||
case "ConnectedToProxy":
|
||||
if(strlen($error = $this->ConnectFromProxy($arguments, $headers)))
|
||||
return($error);
|
||||
$connect = 1;
|
||||
break;
|
||||
default:
|
||||
return($this->SetError("can not send request in the current connection state", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
}
|
||||
if(IsSet($arguments["RequestMethod"]))
|
||||
$this->request_method=$arguments["RequestMethod"];
|
||||
if(IsSet($arguments["User-Agent"]))
|
||||
$this->user_agent=$arguments["User-Agent"];
|
||||
if(!IsSet($arguments["Headers"]["User-Agent"])
|
||||
&& strlen($this->user_agent))
|
||||
$arguments["Headers"]["User-Agent"]=$this->user_agent;
|
||||
if(IsSet($arguments["KeepAlive"]))
|
||||
$this->keep_alive=intval($arguments["KeepAlive"]);
|
||||
if(!IsSet($arguments["Headers"]["Connection"])
|
||||
&& $this->keep_alive)
|
||||
$arguments["Headers"]["Connection"]='Keep-Alive';
|
||||
if(IsSet($arguments["Accept"]))
|
||||
$this->user_agent=$arguments["Accept"];
|
||||
if(!IsSet($arguments["Headers"]["Accept"])
|
||||
&& strlen($this->accept))
|
||||
$arguments["Headers"]["Accept"]=$this->accept;
|
||||
if(strlen($this->request_method)==0)
|
||||
return($this->SetError("it was not specified a valid request method", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
if(IsSet($arguments["RequestURI"]))
|
||||
$this->request_uri=$arguments["RequestURI"];
|
||||
if(strlen($this->request_uri)==0
|
||||
|| substr($this->request_uri,0,1)!="/")
|
||||
return($this->SetError("it was not specified a valid request URI", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
$this->request_arguments=$arguments;
|
||||
$this->request_headers=(IsSet($arguments["Headers"]) ? $arguments["Headers"] : array());
|
||||
$body_length=0;
|
||||
$this->request_body="";
|
||||
$get_body=1;
|
||||
if($this->request_method=="POST"
|
||||
|| $this->request_method=="PUT")
|
||||
{
|
||||
if(IsSet($arguments['StreamRequest']))
|
||||
{
|
||||
$get_body = 0;
|
||||
$this->request_headers["Transfer-Encoding"]="chunked";
|
||||
}
|
||||
elseif(IsSet($arguments["PostFiles"])
|
||||
|| ($this->force_multipart_form_post
|
||||
&& IsSet($arguments["PostValues"])))
|
||||
{
|
||||
$boundary="--".md5(uniqid(time()));
|
||||
$this->request_headers["Content-Type"]="multipart/form-data; boundary=".$boundary.(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : "");
|
||||
$post_parts=array();
|
||||
if(IsSet($arguments["PostValues"]))
|
||||
{
|
||||
$values=$arguments["PostValues"];
|
||||
if(GetType($values)!="array")
|
||||
return($this->SetError("it was not specified a valid POST method values array", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
for(Reset($values),$value=0;$value<count($values);Next($values),$value++)
|
||||
{
|
||||
$input=Key($values);
|
||||
$headers="--".$boundary."\r\nContent-Disposition: form-data; name=\"".$input."\"\r\n\r\n";
|
||||
$data=$values[$input];
|
||||
$post_parts[]=array("HEADERS"=>$headers,"DATA"=>$data);
|
||||
$body_length+=strlen($headers)+strlen($data)+strlen("\r\n");
|
||||
}
|
||||
}
|
||||
$body_length+=strlen("--".$boundary."--\r\n");
|
||||
$files=(IsSet($arguments["PostFiles"]) ? $arguments["PostFiles"] : array());
|
||||
Reset($files);
|
||||
$end=(GetType($input=Key($files))!="string");
|
||||
for(;!$end;)
|
||||
{
|
||||
if(strlen($error=$this->GetFileDefinition($files[$input],$definition)))
|
||||
return("3 ".$error);
|
||||
$headers="--".$boundary."\r\nContent-Disposition: form-data; name=\"".$input."\"; filename=\"".$definition["NAME"]."\"\r\nContent-Type: ".$definition["Content-Type"]."\r\n\r\n";
|
||||
$part=count($post_parts);
|
||||
$post_parts[$part]=array("HEADERS"=>$headers);
|
||||
if(IsSet($definition["FILENAME"]))
|
||||
{
|
||||
$post_parts[$part]["FILENAME"]=$definition["FILENAME"];
|
||||
$data="";
|
||||
}
|
||||
else
|
||||
$data=$definition["DATA"];
|
||||
$post_parts[$part]["DATA"]=$data;
|
||||
$body_length+=strlen($headers)+$definition["Content-Length"]+strlen("\r\n");
|
||||
Next($files);
|
||||
$end=(GetType($input=Key($files))!="string");
|
||||
}
|
||||
$get_body=0;
|
||||
}
|
||||
elseif(IsSet($arguments["PostValues"]))
|
||||
{
|
||||
$values=$arguments["PostValues"];
|
||||
if(GetType($values)!="array")
|
||||
return($this->SetError("it was not specified a valid POST method values array", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
for(Reset($values),$value=0;$value<count($values);Next($values),$value++)
|
||||
{
|
||||
$k=Key($values);
|
||||
if(GetType($values[$k])=="array")
|
||||
{
|
||||
for($v = 0; $v < count($values[$k]); $v++)
|
||||
{
|
||||
if($value+$v>0)
|
||||
$this->request_body.="&";
|
||||
$this->request_body.=UrlEncode($k)."=".UrlEncode($values[$k][$v]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($value>0)
|
||||
$this->request_body.="&";
|
||||
$this->request_body.=UrlEncode($k)."=".UrlEncode($values[$k]);
|
||||
}
|
||||
}
|
||||
$this->request_headers["Content-Type"]="application/x-www-form-urlencoded".(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : "");
|
||||
$get_body=0;
|
||||
}
|
||||
}
|
||||
if($get_body
|
||||
&& (IsSet($arguments["Body"])
|
||||
|| IsSet($arguments["BodyStream"])))
|
||||
{
|
||||
if(IsSet($arguments["Body"]))
|
||||
$this->request_body=$arguments["Body"];
|
||||
else
|
||||
{
|
||||
$stream=$arguments["BodyStream"];
|
||||
$this->request_body="";
|
||||
for($part=0; $part<count($stream); $part++)
|
||||
{
|
||||
if(IsSet($stream[$part]["Data"]))
|
||||
$this->request_body.=$stream[$part]["Data"];
|
||||
elseif(IsSet($stream[$part]["File"]))
|
||||
{
|
||||
if(!($file=@fopen($stream[$part]["File"],"rb")))
|
||||
return($this->SetPHPError("could not open upload file ".$stream[$part]["File"], $php_errormsg, HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE));
|
||||
while(!feof($file))
|
||||
{
|
||||
if(GetType($block=@fread($file,$this->file_buffer_length))!="string")
|
||||
{
|
||||
$error=$this->SetPHPError("could not read body stream file ".$stream[$part]["File"], $php_errormsg, HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE);
|
||||
fclose($file);
|
||||
return($error);
|
||||
}
|
||||
$this->request_body.=$block;
|
||||
}
|
||||
fclose($file);
|
||||
}
|
||||
else
|
||||
return("5 it was not specified a valid file or data body stream element at position ".$part);
|
||||
}
|
||||
}
|
||||
if(!IsSet($this->request_headers["Content-Type"]))
|
||||
$this->request_headers["Content-Type"]="application/octet-stream".(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : "");
|
||||
}
|
||||
if(IsSet($arguments["AuthUser"]))
|
||||
$this->request_user=$arguments["AuthUser"];
|
||||
elseif(IsSet($this->user))
|
||||
$this->request_user=$this->user;
|
||||
if(IsSet($arguments["AuthPassword"]))
|
||||
$this->request_password=$arguments["AuthPassword"];
|
||||
elseif(IsSet($this->password))
|
||||
$this->request_password=$this->password;
|
||||
if(IsSet($arguments["AuthRealm"]))
|
||||
$this->request_realm=$arguments["AuthRealm"];
|
||||
elseif(IsSet($this->realm))
|
||||
$this->request_realm=$this->realm;
|
||||
if(IsSet($arguments["AuthWorkstation"]))
|
||||
$this->request_workstation=$arguments["AuthWorkstation"];
|
||||
elseif(IsSet($this->workstation))
|
||||
$this->request_workstation=$this->workstation;
|
||||
if(strlen($this->proxy_host_name)==0
|
||||
|| $connect)
|
||||
$request_uri=$this->request_uri;
|
||||
else
|
||||
{
|
||||
switch(strtolower($this->protocol))
|
||||
{
|
||||
case "http":
|
||||
$default_port=80;
|
||||
break;
|
||||
case "https":
|
||||
$default_port=443;
|
||||
break;
|
||||
}
|
||||
$request_uri=strtolower($this->protocol)."://".$this->host_name.(($this->host_port==0 || $this->host_port==$default_port) ? "" : ":".$this->host_port).$this->request_uri;
|
||||
}
|
||||
if($this->use_curl)
|
||||
{
|
||||
$version=(GetType($v=curl_version())=="array" ? (IsSet($v["version"]) ? $v["version"] : "0.0.0") : (preg_match("/^libcurl\\/([0-9]+\\.[0-9]+\\.[0-9]+)/",$v,$m) ? $m[1] : "0.0.0"));
|
||||
$curl_version=100000*intval($this->Tokenize($version,"."))+1000*intval($this->Tokenize("."))+intval($this->Tokenize(""));
|
||||
$protocol_version=($curl_version<713002 ? "1.0" : $this->protocol_version);
|
||||
}
|
||||
else
|
||||
$protocol_version=$this->protocol_version;
|
||||
$this->request=$this->request_method." ".$request_uri." HTTP/".$protocol_version;
|
||||
if($body_length
|
||||
|| ($body_length=strlen($this->request_body))
|
||||
|| !strcmp($this->request_method, 'POST'))
|
||||
$this->request_headers["Content-Length"]=$body_length;
|
||||
for($headers=array(),$host_set=0,Reset($this->request_headers),$header=0;$header<count($this->request_headers);Next($this->request_headers),$header++)
|
||||
{
|
||||
$header_name=Key($this->request_headers);
|
||||
$header_value=$this->request_headers[$header_name];
|
||||
if(GetType($header_value)=="array")
|
||||
{
|
||||
for(Reset($header_value),$value=0;$value<count($header_value);Next($header_value),$value++)
|
||||
$headers[]=$header_name.": ".$header_value[Key($header_value)];
|
||||
}
|
||||
else
|
||||
$headers[]=$header_name.": ".$header_value;
|
||||
if(strtolower(Key($this->request_headers))=="host")
|
||||
{
|
||||
$this->request_host=strtolower($header_value);
|
||||
$host_set=1;
|
||||
}
|
||||
}
|
||||
if(!$host_set)
|
||||
{
|
||||
$headers[]="Host: ".$this->host_name;
|
||||
$this->request_host=strtolower($this->host_name);
|
||||
}
|
||||
if(count($this->cookies))
|
||||
{
|
||||
$cookies=array();
|
||||
$this->PickCookies($cookies,0);
|
||||
if(strtolower($this->protocol)=="https")
|
||||
$this->PickCookies($cookies,1);
|
||||
if(count($cookies))
|
||||
{
|
||||
$h=count($headers);
|
||||
$headers[$h]="Cookie:";
|
||||
for(Reset($cookies),$cookie=0;$cookie<count($cookies);Next($cookies),$cookie++)
|
||||
{
|
||||
$cookie_name=Key($cookies);
|
||||
$headers[$h].=" ".$cookie_name."=".$cookies[$cookie_name]["value"].";";
|
||||
}
|
||||
}
|
||||
}
|
||||
$next_state = "RequestSent";
|
||||
if($this->use_curl)
|
||||
{
|
||||
if(IsSet($arguments['StreamRequest']))
|
||||
return($this->SetError("Streaming request data is not supported when using Curl", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||
if($body_length
|
||||
&& strlen($this->request_body)==0)
|
||||
{
|
||||
for($request_body="",$success=1,$part=0;$part<count($post_parts);$part++)
|
||||
{
|
||||
$request_body.=$post_parts[$part]["HEADERS"].$post_parts[$part]["DATA"];
|
||||
if(IsSet($post_parts[$part]["FILENAME"]))
|
||||
{
|
||||
if(!($file=@fopen($post_parts[$part]["FILENAME"],"rb")))
|
||||
{
|
||||
$this->SetPHPError("could not open upload file ".$post_parts[$part]["FILENAME"], $php_errormsg, HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE);
|
||||
$success=0;
|
||||
break;
|
||||
}
|
||||
while(!feof($file))
|
||||
{
|
||||
if< | ||||