[英]Using OpenGraph with PHP (cUrl requests for actions)
我為我的網站創建了一個應用程序,設置了動作(閱讀)和對象(文章),並在我網站的文章頁面上放置了對象代碼(頭部的META標簽)。
現在,我想知道當用戶在我的網站上閱讀文章時如何發送cUrl請求,因此它將在他的牆上發布。
當我按下動作附近的“獲取代碼”鏈接時,這就是我得到的:
curl -F 'access_token=***' \
-F 'article=http://example.com' \
'https://graph.facebook.com/me/yellowheart:read'
(當然有一個實際的訪問令牌)。
現在,我該如何實現?
丹尼爾。
使用PHP SDK,您將使用api方法。
$config = array();
$config['appId'] = 'YOUR_APP_ID';
$config['secret'] = 'YOUR_APP_SECRET';
$facebook = new Facebook($config);
...
$facebook->api('https://graph.facebook.com/me/yellowheart:read?
article=http://example.com'','POST');
你也可以做一個原始的請求
$myurl = 'https://graph.facebook.com/me/yellowheart:read?
article=http://example.com&access_token=ACCESS_TOKEN&method=post';
$result = file_get_contents($myurl);
$facebook->api('/me/'.FB_NAME_SPACE.':action','POST',
array('facility'=>'http://www.mysite.com/object?id=1')
);
https://developers.facebook.com/docs/reference/php/facebook-api/
我按照教程 “食譜盒”,一步一步地找到了如何“實現它”。 希望在某種程度上有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.