Facebook Requests 2.0 Error #200 All users in param ids must have accepted TOS
I am working on an app through my developer test account and all I am doing is trying to post a test notification to my user. I am doing this using the facebook requests 2.0 documentation, so my code looks like this:
$token_url = "https://graph.facebook.com/oauth/access_to开发者_JAVA百科ken?" .
"client_id=" . $app_id .
"&client_secret=" . $app_secret .
"&grant_type=client_credentials";
$app_access_token = file_get_contents($token_url);
$user_id = $this->user->id;
$apprequest_url ="https://graph.facebook.com/" .
$user_id .
"/apprequests?message='testing notification'" .
"&" .
$app_access_token . "&method=post";
$result = file_get_contents($apprequest_url);
echo "Request id number: " . $result;
When i do this I get an error on the page that says "failed to open stream", however when I copy and paste the url into the address bar I don't get any errors and get returned a request id. Anybody know why this might be happening?
I solved it using curl instead of file_get_contents
. file_get_contents
used to throw errors for some reason.
the cpde for the curl is:
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_URL, $apprequest_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$result = curl_exec($ch);
curl_close($ch);
I know I'm a litle late, but I hope it helps somebody.
You should set allow_url_fopen to On
精彩评论