Category Archives: PHP

Posting to FB pages from web application

This is the code: $appId = ‘YOUR APP ID’; $secret = ‘YOUR SECRET’; $returnurl = ‘http://www.yoursite.com’; $permissions = ‘manage_pages, publish_stream, offline_access’; $fb = new Facebook(array(‘appId’=>$appId, ‘secret’=>$secret)); $fbuser = $fb->getUser(); if($fbuser){ $page_id = “YOUR PAGE ID”; $page_access_token = “GET PAGE TOKEN ID”; $result = $fb->api(“/me/accounts”); // loop trough all your pages and find the right one […]

Shortening URL with Goo.gl and PHP

// This is the URL you want to shorten $longUrl = ‘http://www.mysite.com/’; // Get API key from : http://code.google.com/apis/console/ $apiKey = ‘MyAPIKey’; $postData = array(‘longUrl’ => $longUrl, ‘key’ => $apiKey); $jsonData = json_encode($postData); $curlObj = curl_init(); curl_setopt($curlObj, CURLOPT_URL, ‘https://www.googleapis.com/urlshortener/v1/url’); curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curlObj, CURLOPT_HEADER, 0); curl_setopt($curlObj, CURLOPT_HTTPHEADER, array(‘Content-type:application/json’)); curl_setopt($curlObj, CURLOPT_POST, 1); curl_setopt($curlObj, […]