2012-05-26 155 views
0

我想向用户发送消息,但它不起作用。任何想法为什么?用Facebook API向用户发送消息

<?php 

    $app_id = '####'; 
    $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_token = file_get_contents($token_url); 

    $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); 
    echo "Request id number: ". $result; 

?> 

回答

0

这是不发送POST请求

$apprequest_url ="https://graph.facebook.com/" . 
    $user_id . 
    "/apprequests?message='INSERT_UT8_STRING_MSG'" . 
    "&data='INSERT_STRING_DATA'&" . 
    $app_access_token . "&method=post"; 

您应该使用PHP卷曲发送POST请求或check this

方式
相关问题