【问题标题】:Problem using publishUserAction method to post to profile使用 publishUserAction 方法发布到配置文件的问题
【发布时间】:2011-01-28 23:59:39
【问题描述】:

我正在使用 gigya php sdk,效果很好我可以使用 socialise.setStatus 方法发布到用户的墙或个人资料,但是当我尝试使用 publishuseraction 方法时遇到问题。我收到错误请求签名无效。

$method = "socialize.publishUserAction";

$request = new GSRequest($apiKey,$secretKey,$method);

$userAction = new GSDictionary("{\"title\":\"This is my title\", \"userMessage\":\"This is a user message\", \"description\":\"This is a description\",      \"linkBack\":\"http://google.com\", \"mediaItems\":[{\"src\":\"http://www.f2h.co.il/logo.jpg\", \"href\":\"http://www.f2h.co.il\",\"type\":\"image\"}]}"); 

$request->setParam("userAction", $userAction);  

$request->setParam("uid", $userUID);  

$response = $request->send();

if($response->getErrorCode()==0){ 
    echo "Success";   
} else { 
    echo ("Error: " . $response->getErrorMessage());
}

使用 $response->getLog() 后更新

apiMethod=socialize.publishUserAction
apiKey=correct_api_key
params={"userAction":{},uid":"MY_UID","format":"json","httpStatusCodes":"false"}
URL=http://socialize.gigya.com/socialize.publishUserAction    postData=uid=urlencoded(MY_UID)&format=json&httpStatusCodes=false&apiKey=correct_api_key×tamp=1296229876&nonce=1.29622987636E%2B12&sig=HEdzy%2BzxetV8QvTDjdsdMWh0%2Fz8%3D
server= web504

两个put方法我都用过

$userAction = new GSDictionary();

$userAction->put("title", "This is my title");
$userAction->put("userMessage", "This is my user message");
$userAction->put("description", "This is my description");
$userAction->put("linkBack", "http://google.com");

$mediaItems = array();
$mediaItems[0] = new GSDictionary("{\"src\":\"http://www.f2h.co.il/logo.jpg\", \"href\":\"http://www.f2h.co.il\",\"type\":\"image\"}");

&JSON 方法

$userAction = new GSDictionary("{\"title\":\"This is my title\", \"userMessage\":\"This is a user message\", \"description\":\"This is a description\", 
     \"linkBack\":\"http://google.com\", \"mediaItems\":[ {\"src\":\"http://www.f2h.co.il/logo.jpg\", \"href\":\"http://www.f2h.co.il\",\"type\":\"image\"}]}");

我得到同样的错误。并且使用这两种方法的用户操作都是空的。感谢您的帮助。

谢谢。

【问题讨论】:

    标签: php sdk gigya


    【解决方案1】:

    尝试调用 getLog() 以获取有关错误的更多信息:

    if($response->getErrorCode()==0){ 
        echo "Success";   
    } else { 
        echo ("Error: " . $response->getErrorMessage());
        print "<pre>";
        print_r($response->getLog());
        print "</pre>";
    }
    

    另外,您可以使用 SDK 运行 getUserInfo 吗?这是一个简单的测试,也需要签名。使用 PHP SDK 页面上的示例(大约向下 1/2)。

    【讨论】:

    • 谢谢。我确实按照您的指示尝试了 getUserInfo 它工作正常。我能够获取用户的详细信息。然后,我确实尝试在更新代码后发布到用户的墙上。仍然相同的错误无效的请求签名。在日志中
    • 我发现 userAction 使用这两种方法都是空的。我已经更新了问题中的日志和我的 userActions。我感谢您的帮助。再次感谢。
    • 终于让它工作了。但我无法添加带有图像或视频等的媒体项目,错误:无效参数值“errorDetails”:“无效参数:媒体项目中缺少'类型'字段”我有类型字段。感谢您的帮助。
    猜你喜欢
    • 2023-02-20
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 2010-11-16
    • 1970-01-01
    • 1970-01-01
    • 2011-09-19
    • 2012-07-11
    相关资源
    最近更新 更多