Thursday, April 4, 2013

send request from app to user using php


<?php

  $app_id = "YOUR_APP_ID";
  $app_secret = "YOUR_APP_SECRET";
  $token_url = "https://graph.facebook.com/oauth/access_token?" .
    "client_id=" . $app_id .
    "&client_secret=" . $app_secret .
    "&grant_type=client_credentials";
  $app_access= file_get_contents($token_url);
  $app_access_token = json_decode($app_access, true);
  $user_id ="USER_ID";
  $apprequest_url ="https://graph.facebook.com/" .
    $user_id .
    "/apprequests?message='INSERT_UT8_STRING_MSG'" .
    "&data='INSERT_STRING_DATA'&"  .  
    $app_access_token . "&method=post";
  $result = file_get_contents($apprequest_url);
  $obj = json_decode($result, true);
  print_r($app_access_token);
  print_r($obj);
  
?>

No comments:

Post a Comment