Pages

Wednesday, December 21, 2011

Uploading docx file in Code Igniter

1. Go to system->config directory.
2. Open the mimes.php file.
3. Add

'docx'    =>  'application/vnd.openxmlformats-officedocument.wordprocessingml.document'

at the end of the array.

4. Also add the `docx` in the allowed_types list where the upload library is called as configuration parameter.

Thursday, December 1, 2011

Publishing text in a Facebook page

Below is the core code using the facebook graph API in PHP, cURL is required:

It is assumed the PHP variables containing proper data.the $attachment array keys can be added or removed necessarily.

<?php
$ch = curl_init();
$url="https://graph.facebook.com/<PAGE ID>/feed?access_token=<APP API KEY>|<APP Secret>";
$attachment = array(
'access_token' => "$access_token",
'message' =>"$message",
'name' => "New Session!",
'link' => "$purl",
'description' => ' ',
'picture'=>"<PICTURE URL>",
);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close ($ch);
?>