If (function_exists (' Curl_init '))
{
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url _with_get);
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_postfields, $post);
curl_setopt ($ch, Curlopt_returntransfer, true);
$result = curl_exec ($ch);
Curl_close ($ch);
}
Else
{
$content = http_build_query ($post)
$content _length = strlen ($content);
$context =
Array (' http ' =>
Array (' method ' => ' post ',
' user_agent ' => $user _agent,
' H Eader ' => ' content-type: '. $content _type. " " .
' content-length: '. $content _length,
' content ' => $content));
$context _id = stream_context_create ($context);
$sock = fopen ($url _with_get, ' R ', False, $context _id);
$result = ';
if ($sock)
{
while (!feof ($sock))
$result. = Fgets ($sock, 4096);
Fclose ($sock);
}
return $result;
}
}
Test code
| The code is as follows |
Copy Code |
|
$url _with_get= "Http://api.facebook.com/restserver.php?method=facebook.friends.get&session_key=&api_key =1232121311&v=1.0 ";
$post = Array (' sig ' =>12312123234353);
|