arze ramade
arze ramade

Reputation: 317

Local parameter on Facebook issue

I have written this Python code to retrieve all Facebook pages that are written in Arabic:

import facebook # pip install facebook-sdk
import json
import codecs
from prettytable import PrettyTable
from collections import Counter

# A helper function to pretty-print Python objects as JSON

def pp(o): 
    print json.dumps(o, indent=1)

# Create a connection to the Graph API with your access token

ACCESS_TOKEN = ''#my access token
g = facebook.GraphAPI(ACCESS_TOKEN)


s=g.request('search', { 'q' : '&',
                        'type' : 'page', 
                        'limit' : 5000 , 
                        'locale' : 'ar_AR' })

pp(s)

The locale parameter should return all pages written in Arabic. However, as the output below shows, I get results that contain English. What am I doing incorrectly?

{
 "paging": {

 "data": [
  {
   "category": "\u0628\u0636\u0627\u0626\u0639 \u0627\u0644\u0628\u064a\u0639 \u0628\u0627\u0644\u062a\u062c\u0632\u0626\u0629 \u0648\u0628\u0636\u0627\u0626\u0639 \u0627\u0644\u0645\u0633\u062a\u0647\u0644\u0643\u064a\u0646", 
   "name": "Stop & Shop", 
   "category_list": [
    {
     "id": "169207329791658", 
     "name": "\u0645\u062d\u0644 \u0628\u0642\u0627\u0644\u0629"
    }
   ], 
   "id": "170000993071234"
  }, 
  {
   "category": "\u0628\u0636\u0627\u0626\u0639 \u0627\u0644\u0628\u064a\u0639 \u0628\u0627\u0644\u062a\u062c\u0632\u0626\u0629 \u0648\u0628\u0636\u0627\u0626\u0639 \u0627\u0644\u0645\u0633\u062a\u0647\u0644\u0643\u064a\u0646", 
   "name": "C&A", 
   "category_list": [
    {
     "id": "186230924744328", 
     "name": "\u0645\u062a\u062c\u0631 \u0645\u0644\u0627\u0628\u0633"
    }
   ], 
   "id": "109345009145382"
  },

Upvotes: 1

Views: 97

Answers (1)

William Denman
William Denman

Reputation: 3164

Your query is 100% correct and should only return Arabic posts. Unfortunately, this is a known Facebook Graph Search API bug. It looks like it flips back and forth from working to not working.

See the discussions, https://developers.facebook.com/bugs/294623187324442 and https://developers.facebook.com/bugs/409365862525282

I had similar issues working with the Facebook Graph API, it never seems to work quite right.

Upvotes: 1

Related Questions