Make REST calls in PHP

Example of calling GET request
//next example will recieve all messages for specific conversation
$service_url = '[CONV_CODE]/messages&apikey=[API_KEY]';
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
if ($curl_response === false) {
    $info = curl_getinfo($curl);
    die('error occured during curl exec. Additioanl info: ' . var_export($info));
$decoded = json_decode($curl_response);
if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') {
    die('error occured: ' . $decoded->response->errormessage);
echo 'response ok!';

Continue reading

PHP Requests Library within CodeIgniter

Simple way to use Requests for PHP with Codeigniter.

You may follow these few easy steps.

Step – 1

Unzip latest Requests for PHP zip and copy the contents of the library directory to {codeigniter_directory}/application/third_party/Request-{version} for example you have Requests for PHP 1.6.0 and your CI project is in /usr/sites/www/myproject then copy the files to /usr/sites/www/myproject/application/third_party/Requests-1.6.0.

Continue reading

Apache: Enable PHP in UserDir

Here is a tip to PHP developers that uses the Debian family of distros: how enable the execution of PHP scripts in the public_html folder. Apparently, this feature is disabled by default in the Debian based distros. Before start, I’m assuming that you already have both Apache and PHP installed, configured and running.

Continue reading


If you don’t have access to configure Apache, you can still send the header from a PHP script. It’s a case of adding the following to your PHP scripts:

 header("Access-Control-Allow-Origin: *");

Note: as with all uses of the PHP header function, this must be before any output has been sent from the server.

in PHP | 55 Words

Dynamically Add Javascript and CSS Files in CodeIgniter Header Page

Those who are developing web projects know that, header pages are always the constant file of their template folder. The classic way of using a header page in small projects are to fill it with constant JavaScript and CSS files along with html tags and use it in inside functions where you need. The problem arise when you start to develop a bigger project where you need to use different JavaScript and CSS files. The bad practice is to load all needed files in the header page, that will also start to appear and load in the pages and sections which we do not need them. This will make the page load slow and will cause conflicts and usage problems.

Continue reading