1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Face fan page wall post using php SDK

Discussion in 'Facebook API' started by praveenvijay, Jan 21, 2014.

  1. #1
    Dear all,

    In my website admin page.post a new property.the details are posted in my facebook fan page wall. I am using PHP SDK.
    Some times its working fine.
    Sometimes redirect to my return url it contains code parameter and stopped
    i am using this code

    Anyone help me

    <?php
    require_once 'src/facebook.php';
    // configuration
    $appid = '';
    $appsecret = '';
    $pageId = '';
    $msg = $_REQUEST['fbtitle'];
    $title = $_REQUEST['fbtitle'];
    $uri = $_REQUEST['fburl'];
    $desc = $_REQUEST['fbsum'];
    $pic = $_REQUEST['fbimage'];




    $facebook = new Facebook(array(
    'appId' => $appid,
    'secret' => $appsecret,
    'cookie' => false,
    ));
    SEMrush


    $user = $facebook->getUser();

    // Contact Facebook and get token
    if ($user) {
    // you're logged in, and we'll get user acces token for posting on the wall
    try {



    $page_info = $facebook->api("/$pageId?fields=access_token");

    if (!empty($page_info['access_token'])) {
    $attachment = array(
    'access_token' => $page_info['access_token'],
    'message' => $msg,
    'name' => $title,
    'link' => $uri,
    'description' => $desc,
    'caption' => $caption,
    'picture'=>$pic,
    'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
    );

    $status = $facebook->api("/$pageId/feed", "post", $attachment);

    $msg="<h2 align='center'>Sucessfully Posted On Facebook Wall</h2>";
    }
    else
    {




    $status = 'No access token recieved';
    }

    }
    catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
    }
    } else
    {
    // you're not logged in, the application will try to log in to get a access token


    header("Location:{$facebook->getLoginUrl(array('scope' => 'photo_upload,user_status,publish_stream,user_photos,manage_pages'))}");
    }


    echo $msg;
    ?>
     
    praveenvijay, Jan 21, 2014 IP
    SEMrush
  2. easyolcash

    easyolcash Active Member

    Messages:
    302
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    80
    Digital Goods:
    1
    #2
    easyolcash, Feb 26, 2014 IP
    tonyrocks likes this.
  3. Dixanta Shrestha

    Dixanta Shrestha Active Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #3
    you need manage_pages permission and after that you can do me/accounts to list all the pages you are admin of from there you can get page access_token using that token you can post on behalf of page cheers :)
     
    Dixanta Shrestha, Jun 4, 2014 IP