使用 NSURL 请求时 URL 错误
我试图在 iPhone 4.0 SDK 中请求这种 URL(访问令牌稍作修改,因为您实际上不需要看到它):
https://graph.facebook.com/me?sdk=ios&sdk_version=2&access_token=123902817987|8cb9e8408d2685cef853cd80.9-747882379|UGu5NvcAHiXuGEGzkq&format=json&limit=40&until=1286619821
但我收到此消息:
Failed with error: Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x9e657a0 {NSUnderlyingError=0x9e656a0 "bad URL", NSLocalizedDescription=bad URL}
当我在 Safari 或 Chrome 中复制并粘贴时,它可以工作。我尝试按照建议将 |
替换为 %|
此处 但不起作用。
从终端询问是这样的:
curl https://graph.facebook.com/me/statuses?sdk=ios&sdk_version=2&access_token=9999955817987|8ab9e8408d2685cef.3-747882379|UGuxWDuM&format=json&limit=40&until=1286619821
[1] 16190
[2] 16191
[3] 16194
[4] 16195
[5] 16196
[2] Done sdk_version=2
[4]- Done format=json
$ -bash: UGu5NvcAHiXuGEGzkq3KP8xWDuM: command not found
-bash: 8ab9e8408d2685cef853cd80.3-747882379: command not found
{"error":{"type":"OAuthException","message":"An active access token must be used to query information about the current user."}}
[1] Done curl https://graph.facebook.com/me/statuses?sdk=ios
[3]- Exit 127 access_token=9999955817987 | 8ab9e8408d2685cef.3-747882379 | UGuxWDuM
[5]+ Done limit=40
有什么想法吗?
I'm trying to request this kind of URL in iPhone 4.0 SDK (access token slightly modified because you don't really need to see it):
https://graph.facebook.com/me?sdk=ios&sdk_version=2&access_token=123902817987|8cb9e8408d2685cef853cd80.9-747882379|UGu5NvcAHiXuGEGzkq&format=json&limit=40&until=1286619821
But I got this message:
Failed with error: Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x9e657a0 {NSUnderlyingError=0x9e656a0 "bad URL", NSLocalizedDescription=bad URL}
When I copied and pasted in Safari or Chrome, it works. I tried replacing |
with %|
as suggested here but doesn't work.
Asking it from the terminal looks like this:
curl https://graph.facebook.com/me/statuses?sdk=ios&sdk_version=2&access_token=9999955817987|8ab9e8408d2685cef.3-747882379|UGuxWDuM&format=json&limit=40&until=1286619821
[1] 16190
[2] 16191
[3] 16194
[4] 16195
[5] 16196
[2] Done sdk_version=2
[4]- Done format=json
$ -bash: UGu5NvcAHiXuGEGzkq3KP8xWDuM: command not found
-bash: 8ab9e8408d2685cef853cd80.3-747882379: command not found
{"error":{"type":"OAuthException","message":"An active access token must be used to query information about the current user."}}
[1] Done curl https://graph.facebook.com/me/statuses?sdk=ios
[3]- Exit 127 access_token=9999955817987 | 8ab9e8408d2685cef.3-747882379 | UGuxWDuM
[5]+ Done limit=40
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要将 URL 中的管道字符替换为
%7C
。这是 URL 编码值。此外,URL 需要用引号括起来,以便与curl 一起使用。
You need to replace the pipe character in the URL with
%7C
. This is the URL encoded value.Also, the URL needs to be enclosed in quotation marks in order for it to work with curl.
嗬嗬嗬。
使用您想要的地点的 ID 设置
location_id
。这让我浪费了很多时间。
Facebook 的十几个秘密之一是在制作你想要的东西时调试网络,在本例中创建一个事件。您将看到所需的正确参数名称。
ho ho ho.
Set
location_id
using the id of the venue you want.This make me waste a lot of time.
One of dozen facebook secrets is debug network when making what you want, in this case creating a event. You'll see the correct params names for what you need.
此错误消息也可能是由 URL 输入中的任何错误引起的。 URL 字符串中通常有一些空格。
This error message, also can be caused by any error in the URL typing. Usually some white space in the URL string.