Facebook page feed - Invalid parameter:Url argument was malformed URL

Hi guys,

I’m curently working on my mobile application which reads data from Facebook page and shows them on the screen. I’ve already finished my application for Android and I didn’t have any problems. But with iOS I’m having huge problem.

When I receive access token and try to get data(using method network.request method) I get an error: “Invalid Parameter URL argument was malformed url”. Don’t know what’s the problem: wrote FB app ID in build settings, added iOS application on Facebook developers account…

Here is part of the code that is causing problems

function readData(event)

print(event.response) --this is access token that I get

local link="https://graph.facebook.com/"…APPID…"/posts?"…tostring(event.response);

print(link);

network.request(link,“GET”,readFacebookData); 

end

Does anyone had similiar problem?

OK still couldn’t find solution after some researching but now I have some doubt: am I getting correct access token? Because mine has some symbols like _ or  |

I’m asking for access token like this:

network.request("https://graph.facebook.com/oauth/access\_token?client\_id="..MY\_CLIENT\_ID.."&client\_secret="..MY\_CLIENT\_SECRET.."&grant\_type=client\_credentials","GET",readData); function readData(event) local link="https://graph.facebook.com/"..PAGE\_ID.."/posts?"..tostring(event.response); print(link); network.request(link,"GET",readFacebookData); end

As a response I get access token and after that I receive mentioned message. So, is there maybe problem with URL which now contains symbols like “|” or “_” ? But all this works great on Android. With iOS version I’m having problems.

 

Is there a reason you are making direct API calls instead of using the built in facebook.* API calls?

Rob

Yes, I’m not using facebook* API calls because I just want to get posts from FB page without forcing user to login to Facebook

bump

Android and iOS (and other OS’s) may handle network URL content slightly different when it comes to special characters. You may need to escape special characters on iOS to make it work.

To troubleshoot what is going on, you can use http://requestb.in to view how the URL is formed. Just create a page on the site and use the URL in place of your Facebook URL to see what is actually being sent. You can do this from Android and iOS to see the differences.

Thanks Tom, I’ve tried this website but unfortunatelly it didn’t help me. I’ve created page and entered my Facebook and got Runscope URL. I’ve tried with that new url but again I get the same message, even with that Runscope URL. On Android it works perfect, and on requestb.in website I can see results. Am I doing something wrong with this service?

Still couldn’t find solution for this problem. I tried to encode/decode url, to escape characters but nothing. On my Facebook account app is in Development mode, I’ve inserted all info about ios app(like app Bundle ID etc). And website http://requestb.in  didn’t helped me much.

Is it posible to get facebook feed without logging with some account? 

Tried also on  iPhone device and also cannot get news feed. Anyone?

OK still couldn’t find solution after some researching but now I have some doubt: am I getting correct access token? Because mine has some symbols like _ or  |

I’m asking for access token like this:

network.request("https://graph.facebook.com/oauth/access\_token?client\_id="..MY\_CLIENT\_ID.."&client\_secret="..MY\_CLIENT\_SECRET.."&grant\_type=client\_credentials","GET",readData); function readData(event) local link="https://graph.facebook.com/"..PAGE\_ID.."/posts?"..tostring(event.response); print(link); network.request(link,"GET",readFacebookData); end

As a response I get access token and after that I receive mentioned message. So, is there maybe problem with URL which now contains symbols like “|” or “_” ? But all this works great on Android. With iOS version I’m having problems.

 

Is there a reason you are making direct API calls instead of using the built in facebook.* API calls?

Rob

Yes, I’m not using facebook* API calls because I just want to get posts from FB page without forcing user to login to Facebook

bump

Android and iOS (and other OS’s) may handle network URL content slightly different when it comes to special characters. You may need to escape special characters on iOS to make it work.

To troubleshoot what is going on, you can use http://requestb.in to view how the URL is formed. Just create a page on the site and use the URL in place of your Facebook URL to see what is actually being sent. You can do this from Android and iOS to see the differences.

Thanks Tom, I’ve tried this website but unfortunatelly it didn’t help me. I’ve created page and entered my Facebook and got Runscope URL. I’ve tried with that new url but again I get the same message, even with that Runscope URL. On Android it works perfect, and on requestb.in website I can see results. Am I doing something wrong with this service?

Still couldn’t find solution for this problem. I tried to encode/decode url, to escape characters but nothing. On my Facebook account app is in Development mode, I’ve inserted all info about ios app(like app Bundle ID etc). And website http://requestb.in  didn’t helped me much.

Is it posible to get facebook feed without logging with some account? 

Tried also on  iPhone device and also cannot get news feed. Anyone?

Did you ever solve this issue? I’m trying to access Facebook’s reporting API and I have characters such as | in my access tokens, which is giving me the same error “Invalid Parameter: URL argument was malformed URL”

Edit:

Fixed it as soon as I’d posted this question. Escaping the whole string was causing problems, so instead I just encoded the | character like so:

fbUserToken = string.gsub( fbUserToken, "|", "%%7c" )

I had to use a double % otherwise gsub threw an error. 

All working now  :slight_smile:

Did you ever solve this issue? I’m trying to access Facebook’s reporting API and I have characters such as | in my access tokens, which is giving me the same error “Invalid Parameter: URL argument was malformed URL”

Edit:

Fixed it as soon as I’d posted this question. Escaping the whole string was causing problems, so instead I just encoded the | character like so:

fbUserToken = string.gsub( fbUserToken, "|", "%%7c" )

I had to use a double % otherwise gsub threw an error. 

All working now  :slight_smile: