[英]Help with CURL in PHP
我正在嘗試用PHP編寫代碼:
curl -F 'access_token=123' \
-F 'message=Hello, Arjun. I like this new API.' \
https://graph.facebook.com/arjun/feed
但我不知道怎么做......
有任何想法嗎?
謝謝
TheBounder。
你不能像這樣執行curl,你必須先安裝一個PHP擴展(cUrl)(在這里查看文檔 )。
然后你可以做這樣的事情:
$url="https://graph.facebook.com/arjun/feed";
$ch = curl_init();
$vars = "message=YourMessage";
if($ch === FALSE){
echo "Errore init curl";
}else{
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
$returned = curl_exec($ch);
$returned = html_entity_decode($returned);
curl_close ($ch);
我剛剛復制了一些我以前用過的代碼,把它當作一個起點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.