1. Go to this page and download the library: Download imsamurai/http-source library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
imsamurai / http-source example snippets
var $myapi = array(
'datasource' => 'MyPlugin.Http/MyPlugin', // Example: 'Github.Http/Github'
'host' => 'api.myplugin.com/v1',
'port' => 80,
'persistent' => false,
'auth' => array(
'name' => 'oauth',
'version' => '1.0', //version 2 not tested, maybe don't work
'oauth_consumer_key' => '--Your API Key--',
'oauth_consumer_secret' => '--Your API Secret--'
),
//all other parameters that passed to config of http socket
//...
);
public $useDbConfig = 'myapi';
public $useTable = 'myapi_table';
App::uses('HttpSourceModel', 'HttpSource.Model');
class Project extends HttpSourceModel {
function findAuthedUserRepos() {
$this->setDataSource('github');
$projects = $this->find('all', array(
//used as repo name if useTable is empty, otherwise used as standart fields parameter
'fields' => 'repos'
));
$this->setDataSource('default'); // if more queries are done later
return $projects;
}
}
:: database.php ::
:: MyModel.php ::
:: bootstrap.php ::
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.