Category Archives: Facebook

Facebook Login with PHP SDK

Github Home:

https://github.com/facebookarchive/php-graph-sdk/tree/master/docs

Install

Sample code to get login URL:

Sample code to get access token

Sample code to get long live token

Get login user data

Note:

Please be aware, that there are issues when using the Facebook SDK together with Guzzle 6.x. php-graph-sdk v5.x only works with Guzzle 5.x out of the box. However, there is a workaround to make it work with Guzzle 6.x.

Brand Rules

https://developers.facebook.com/docs/facebook-login/userexperience/#buttondesign

User click cancel and redirect back with some params

 

Reference:

  1. Facebook SDK for PHP
    https://github.com/facebookarchive/php-graph-sdk/tree/master/docs
  2. Login button:
    https://developers.facebook.com/docs/facebook-login/web/login-button/#——–
  3. Permissions
    https://developers.facebook.com/docs/permissions/reference#user-data
  4. Possible problem
    https://stackoverflow.com/questions/31520593/facebook-php-sdk-5-api-2-4-cross-site-request-forgery-validation-failed-r/36684861#36684861

Product Catalog for Facebook

Use XMLWriter

Generate Facebook Product Catalog Feed (XML)

Facebook Doc: https://developers.facebook.com/docs/marketing-api/dynamic-product-ads/product-catalog#feed-format

CodeIgniter XML Helper:

Sample Code:

 

FB圖片預覽總整理

  1. 中繼標籤必要
  2. 設定圖片寬高(否則第一次預覽圖片不會顯示)

Reference: