简体   繁体   English

instagram api红宝石订阅标签发布访问object_id

[英]instagram api ruby subscription tag post access object_id

the problem that i have is that when i post a picture on Instagram with the good hastag# of my subscription, i receive the notification in my callback but i can't access the object_id in the params. 我的问题是,当我在Instagram上发布具有良好hastag#订阅的图片时,我在回调中收到通知,但无法访问params中的object_id。 Here is the line that i receive : 这是我收到的一行:

Parameters: {"_json"=>[{"changed_aspect"=>"media", "object"=>"tag", "object_id"=>"mytag", "time"=>1439341303, "subscription_id"=>19499294, "data"=>{}}], "subscription"=>{}} 参数:{“ _json” => [{“ changed_aspect” =>“ media”,“ object” =>“ tag”,“ object_id” =>“ mytag”,“ time” => 1439341303,“ subscription_id” => 19499294 ,“数据” => {}}],“订阅” => {}}

Here's my ruby code : 这是我的红宝石代码:

def process_subscription def process_subscription

    if params["hub.challenge"]
        render :text => params["hub.challenge"]
    else
        @test_tag_name =  params["object_id"]
    end

end 结束

But the @test_tag_name is always to null. 但是@test_tag_name始终为null。 Thank you very much 非常感谢你

For those exact params, this would work: params["_json"][0]["object_id"] 对于那些确切的参数,这将起作用: params["_json"][0]["object_id"]

But you'll probably need to adjust based on what params["_json"] will return in the general case (I'm not familiar with that API). 但是您可能需要根据一般情况下返回的params["_json"]进行调整(我不熟悉该API)。 For example, you should probably iterate over the array it returns rather than grabbing the first element. 例如,您可能应该遍历返回的数组,而不是获取第一个元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM