gpt4 book ai didi

java - 没有像 postId 这样的 fb 我刚刚分享成功

转载 作者:太空宇宙 更新时间:2023-11-03 10:21:02 25 4
gpt4 key购买 nike

我已经从我的 Android 应用分享了一个 url 到 FB:

然后我将 postId 保存在一边(硬编码)

我尝试对那个帖子做“fb like”

使用这段代码,却报错:

Button socialBtn3 = (Button) dialog
.findViewById(R.id.socialBtn3);
socialBtn3.setOnClickListener(new OnClickListener() {

String fbPostId = "685560152_10153809399380153";
@Override
public void onClick(View v) {

new LikeFbPostAsyncTask().execute(fbPostId);
}
});

还有这个:

public class LikeFbPostAsyncTask extends AsyncTask<String, Void, Void> {

public LikeFbPostAsyncTask() {
}

@Override
protected void onPreExecute() {
Log.i("LikeFbPostAsyncTask", "Starting web task...");
}

@Override
protected Void doInBackground(String... fbPostId) {

Request likeRequest = new Request(Session.getActiveSession(),
fbPostId + "/likes", null, HttpMethod.POST,
new Request.Callback() {

@Override
public void onCompleted(Response response) {
Log.i(TAG, response.toString());

// how to return to ui thread?
// return response;
}
});
Request.executeBatchAndWait(likeRequest);
return null;

}

@Override
protected void onPostExecute(Void res) {

}
}

{Response: responseCode: 404, graphObject: null, error: {HttpStatus: 404, errorCode: 803, errorType: OAuthException, errorMessage: (#803) Some of the aliases you requested do not exist: [Ljava.lang.String;@4284cd10}, isFromCache:false}

我该如何解决这个问题?

最佳答案

您正在向 AsyncTask (String...) 发送一组字符串参数。从数组中提取所需的字符串时,您应该这样做:

    Request likeRequest = new Request(Session.getActiveSession(),
fbPostId[0] + "/likes", null, HttpMethod.POST,
new Request.Callback() {

代替:

Request likeRequest = new Request(Session.getActiveSession(),
fbPostId + "/likes", null, HttpMethod.POST,
new Request.Callback() {

关于java - 没有像 postId 这样的 fb 我刚刚分享成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21805435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com