PHP Classes

File: demos/simple_link.php

Recommend this page to a friend!
  Classes of Edvaldo Szymonek   PHP Facebook Post to Wall, Pages or Groups   demos/simple_link.php   Download  
File: demos/simple_link.php
Role: Example script
Content type: text/plain
Description: How to publish a simples link
Class: PHP Facebook Post to Wall, Pages or Groups
Send posts to Facebook user profile, pages, groups
Author: By
Last change: Update of demos/simple_link.php
Date: 8 months ago
Size: 667 bytes
 

Contents

Class file image Download
<?php
/**
 * Created by Edvaldo Szymonek
 * User: edvaldo
 * Date: 13/04/2015
 * Time: 09:46
 * Website: http://edvaldotsi.com
 */

require_once "../vendor/autoload.php";

use
FacebookApp\FacebookApp;
use
FacebookApp\Post;
use
FacebookApp\Link;

session_start();
$token = isset($_SESSION["token"]) ? $_SESSION["token"] : null;

$app = new FacebookApp(require "../config/app.config.php");
if (!
$app->checkAccess($token)) {
    exit(
"<a href=\"{$app->getLoginUrl()}\">Fazer login com Facebook</a>");
}

$post = new Post("Testando aplicativo do Facebook");
$post->setLink(new Link("http://www.edvaldotsi.com/"));

$profile = $app->getProfile();
$profile->publish($post);