Module: ZaloAPI::OfficalAccount::Information

Included in:
ZaloAPI::OA
Defined in:
lib/zalo_api/offical_account/information.rb

Instance Method Summary collapse

Instance Method Details

#followers(offset = 0, count = 5) ⇒ Faraday::Response

Get a list of followers

Examples:

res = ZaloAPI::OA.new(client).followers
res.body
{
  "error": int,
  "message": String,
  "data": {
    "total": int,
    "followers": [
      {
        "user_id": String
      },...
    ]
  }
}

Parameters:

  • offset (Integer) (defaults to: 0)

    Start position in the list of people followers

  • count (Integer) (defaults to: 5)

    Number of follower people want to take

Returns:

  • (Faraday::Response)

    List user_id



30
31
32
33
# File 'lib/zalo_api/offical_account/information.rb', line 30

def followers(offset = 0, count =  5)
  param = { offset: offset, count: count }
  @client.connection.get "#{base_url}/oa/getfollowers", { data: param.to_json }
end

#get_conversation_with_user(user_id, offset = 0, count = 5) ⇒ Faraday::Response

Get a list of messages with interested people

Examples:

res = conn.get_conversation_with_user('2512523625412515')
res.body
{
  "error": int,
  "message": String,
  "data": [
    {
      "msg_id": String,
      "src": int,
      "time": int,
      "type": String,
      "message": String,
      "links": JsonObject,
      "thumb": String,
      "url": String,
      "description": String,
      "from_id": Long,
      "to_id": Long,
      "from_display_name": "Huỳnh Hồng Hiển",
      "from_avatar": String,
      "to_display_name": String,
      "to_avatar": String,
      "location": String
    },...
  ]
}

Parameters:

  • user_id (String)
  • offset (Integer) (defaults to: 0)
  • count (Integer) (defaults to: 5)

Returns:

  • (Faraday::Response)


105
106
107
108
# File 'lib/zalo_api/offical_account/information.rb', line 105

def get_conversation_with_user(user_id, offset = 0, count = 5)
  param = { user_id: user_id, offset: offset, count: count }
  @client.connection.get "#{base_url}/oa/conversation", { data: param.to_json }
end

#get_user_profile(user_id) ⇒ Object

Get profile of follower

Examples:

conn.('84123456789')
{
  "error": int,
  "message": String,
  "data": {
      "user_gender": int,
      "user_id": Long,
      "user_id_by_app": Long,
      "avatar": String,
      "avatars": {
          "120": String,
          "240": String
      },
      "display_name": String,
      "birth_date": int,
      "shared_info": String,
      "tags_and_notes_info": {
          "tag_names": Array,
          "notes": Array
      }
  }
}

Parameters:

  • user_id (String)

    Support user_id or phone with country code (ex: 84)



67
68
69
# File 'lib/zalo_api/offical_account/information.rb', line 67

def (user_id)
  @client.connection.get "#{base_url}/oa/getprofile", { data: { user_id: user_id }.to_json }
end

#meObject

Get Offical Account profile



5
6
7
# File 'lib/zalo_api/offical_account/information.rb', line 5

def me
  @client.connection.get "#{base_url}/oa/getoa"
end

#recent_chat(offset = 0, count = 5) ⇒ Object

Get a list of the most recent messages



36
37
38
39
# File 'lib/zalo_api/offical_account/information.rb', line 36

def recent_chat(offset = 0, count =  5)
  param = { offset: offset, count: count }
  @client.connection.get "#{base_url}/oa/listrecentchat", { data: param.to_json }
end