Skip to content

Instantly share code, notes, and snippets.

View iron59's full-sized avatar

iron59 iron59

View GitHub Profile
@iron59
iron59 / deco.cs
Created September 11, 2018 00:59
public void SetDeco(Color decoColor, string attachmentPrefix) {
foreach(Spine.Slot slot in this.spineAnim.Skeleton.Slots) {
if(slot.Data.Name.StartsWith(BodyPartFactory.DECO_SLOT_PREFIX)) {
Spine.Attachment attachment = GetAttachment(attachmentPrefix);
slot.Attachment = attachment;
slot.SetColor(decoColor);
}
}
}
@iron59
iron59 / facebook_api.rb
Created September 12, 2017 01:33
Facebook API Get Reach Estimate v2
def get_target(interest_id, interest_name)
account_id = @account_id
access_token = @access_token
url = "https://graph.facebook.com/v2.10/act_#{account_id}/reachestimate"
params = {
"access_token" => access_token,
"targeting_spec" => "{" +
"\"geo_locations\": {\"country_groups\":[\"Worldwide\"]}," +
" \"age_min\": 20, \"age_max\": 40," +
@iron59
iron59 / error.log
Created September 8, 2017 00:30
Error message from Facebook Marketing API reach estimate call
{
"error": {
"message": "Unsupported post request. Object with ID <ACCOUNT_ID> does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "ESJks9/KxJC"
}
}
@iron59
iron59 / facebook_api.rb
Created September 8, 2017 00:26
Emulating cURL command for reach estimate using Ruby
require 'net/http'
require 'uri'
require "erb"
include ERB::Util
class FacebookApi
def get_target()
account_id = <ACCOUNT_ID>
access_token = <USER_ACCESS_TOKEN_WITH_ADS_MANAGEMENT_PRIVILEGE>
uri = URI.parse("https://graph.facebook.com/v2.10/act_#{account_id}/reachestimate")
@iron59
iron59 / facebook_api.rb
Created September 8, 2017 00:24
Attempt to use Facebook Ads Ruby SDK to get the reach estimate
require "facebook_ads"
class FacebookApi
attr_reader :ad_instance
def initialize(opts={})
@ad_instance = FacebookAds::AdAccount.get("act_#{opts[:account_id]}")
raise 'Account ID Key must be provided' unless opts[:account_id]
end