I want to parse a facebook feed.
Here is my json Url: http://www.facebook.com/feeds/page.php?id=199009743552420&format=json
So I got this type of Data in response:
"content": "\u003Ca href=\"\/l.php?u=http\u00253A\u00252F\u00252Fwww.youtube.com\u00252Fwatch\u00253Fv\u00253D9_PaHtaKAug\u002526list\u00253DPLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n\u002526index\u00253D1\u002526feature\u00253Dplpp_video&h=0AQEQfrMH&s=1\" id=\"\" title=\"\" target=\"\" onclick=\"LinkshimAsyncLink.swap(this, "\\\/l.php?u=http\\u00253A\\u00252F\\u00252Fwww.youtube.com\\u00252Fwatch\\u00253Fv\\u00253D9_PaHtaKAug\\u002526list\\u00253DPLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n\\u002526index\\u00253D1\\u002526feature\\u00253Dplpp_video&h=0AQEQfrMH&s=1");\" style=\"\" rel=\"nofollow\" onmouseover=\"LinkshimAsyncLink.swap(this, "http:\\\/\\\/www.youtube.com\\\/watch?v=9_PaHtaKAug&list=PLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n&index=1&feature=plpp_video");\">\u003Cimg class=\"img\" src=\"http:\/\/external.ak.fbcdn.net\/safe_image.php?d=AQDshpKwwDhCYH9k&w=130&h=130&url=http\u00253A\u00252F\u00252Fi2.ytimg.com\u00252Fvi\u00252F9_PaHtaKAug\u00252Fmqdefault.jpg\" alt=\"\" style=\"height:90px;\" \/>\u003C\/a>\u003Cbr\/>\u003Ca href=\"\/l.php?u=http\u00253A\u00252F\u00252Fwww.youtube.com\u00252Fwatch\u00253Fv\u00253D9_PaHtaKAug\u002526list\u00253DPLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n\u002526index\u00253D1\u002526feature\u00253Dplpp_video&h=PAQEzb06t&s=1\" id=\"\" target=\"_blank\" onclick=\"LinkshimAsyncLink.swap(this, "\\\/l.php?u=http\\u00253A\\u00252F\\u00252Fwww.youtube.com\\u00252Fwatch\\u00253Fv\\u00253D9_PaHtaKAug\\u002526list\\u00253DPLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n\\u002526index\\u00253D1\\u002526feature\\u00253Dplpp_video&h=PAQEzb06t&s=1");\" style=\"\" rel=\"nofollow\" onmouseover=\"LinkshimAsyncLink.swap(this, "http:\\\/\\\/www.youtube.com\\\/watch?v=9_PaHtaKAug&list=PLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n&index=1&feature=plpp_video");\">The Dissident Files - Ausama Monajed at THiNK 2012\u003C\/a>\u003Cbr\/>www.youtube.com\u003Cbr\/>Ausama Monajed in conversation with NDTV's Vishnu Som in Tehelka's THiNK 2012 session on "The Troubled Looking Glass: Why You Should Care About Syria" For mo... "
It contains image logo url, video url, .... so how can I parse this type of data?
Please help me.
Thanking You
Once you have the content field parsed from the json, you will need to parse it again keeping in mind that now you are dealing with html code. If you want to do some complex queries you will have to use XPath with the libxml2 library.
See: iOS: Best way to parse html tags?
If you only want to do a simple query, you can iterate over the string and picking what you want
Related
I want to create JIRA Change Request Ticket using a template.
I use JIRA API endpoint '/rest/api/2/issue'.
Below is the format of the data sent to JIRA.
Could anyone please help?
payload =
{ fields:
{ project: { key: "CRQ"},
customfield_15630: "SampleTemplateName",
summary: "Testing",
customfield_17679: "N.A" ,
customfield_14530:"2018-06-17T00:00:00.0+0000 ",
customfield_14531: "2018-06-17T00:00:00.0+0000 " } }
Here is the XML format of template I want to use in the issue ticket.
<item>
<title>[TMPL-167] NTW-8 [Network_Interface_configuration]</title>
<link>https://jiraqa.com/browse/TMPL-167</link>
<project id="15980" key="TMPL">Templates</project>
<description>Test</description>
<environment />
<key id="492895">TMPL-167</key>
<summary>NTW-8 [Network_Interface_configuration]</summary>
</item>
You are definitely lacking an issue type there. Here is an example of a proper issue creation using the REST API: https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/issue-createIssue
Certain fields may be required or not depending on the project settings, but the project ID, the summary and the issue type are an absolute minimum.
Another thing is that you want to use a template in addition to this. Jira may simply not be able to automatically fetch the data from there, but if anything went wrong, you'd receive an error message anyway.
Could you describe in more detail what exactly do you need to do? It would be easier to come up with a solution ;)
I cannot consistently successfully send form variables that may/may not include special characters e.g. ? & #
Depending on where I try to escape the chars I encounter different errors when reading the data server-side.
I am aware that an update is due for React Native 0.7 to include formdata but wondered if I could safely post objects without needing this.
Someone has already posted a similar issue but no example code was posted to illustrate the POST working:
How to post a form using fetch in react native?
I have tried - amongst other things :
fetch(APIURL, {
method: 'POST',
body: JSON.stringify({
object1: {
param1a: "value 1a",
param1b: "value 1b - with bad chars & # ?",
},
object2:
{
param2a: "value 2a",
param2b: 0,
}
})
})
but it groups the data into a single unnamed parameter (changing the API to accept this is not an option).
also this:
fetch(APIURL, {
method: 'GET',
accessPackage: JSON.stringify({
accessToken: "abc123",
tokenType: 2,
}),
taggData: JSON.stringify({
title: "test",
wishlistID: 0,
anotherVar: "anotherVal"
})
})
I wish to receive the data as two strings that can be parsed as json objects at the other end.
Looking at the the fetch repo https://github.com/github/fetch hasn't helped as this assumes the post with be a full JSON post (which it isn't) or uses FormData which isn't available to React Native yet.
Another solution may be to safely encode/serialise all of the data to URL parameters but this has also proven inconsistent so far especially with the # char.
What's the best way to do this?
"it groups the data into a single unnamed parameter (changing the API
to accept this is not an option)."
It would, because you've set the post body. This is how it's supposed to work.
I wish to receive the data as two strings that can be parsed as json objects at the other end.
You can do whatever you want, but there's no magic happening here. You will receive a single string, the string you set body to. Likewise, the post body can contain anything but shouldn't get confused with "special" characters. Most likely it is your server-side that is causing the problems.
If you want to use FormData then I think it'll be in v0.7.0 which should be out any day now, or you could probably just include the JS file in your own project. You can find it here. Usage examples are in the UIExplorer demo.
After having gotten a site's login form from getSiteLoginForm, I'm attempting to add a site, but I'm receiving
{ :errorOccurred=>"true", :exceptionType=>"Exception Occurred", :referenceCode=>"_fa9ede97-1792-45ca-b147-005ec4002d33" }
The URL I'm POSTing to (in Rails) is:
https://consolidatedsdk.yodlee.com/yodsoap/srest/private-fairshare/v1.0/jsonsdk/SiteAccountManagement/addSiteAccount1
and this is the POST data:
cobSessionToken=REDACTED
userSessionToken=REDACTED
siteId=11671
credentialFields.enclosedType=com.yodlee.common.FieldInfoSingle
credentialFields[0][displayName]=User Name
credentialFields[0][fieldType.typeName]=TEXT
credentialFields[0][isEditable]=true
credentialFields[0][name]=LOGIN
credentialFields[0][value]=testuser
credentialFields[0][valueIdentifier]=LOGIN
credentialFields[0][valueMask]=LOGIN_FIELD
credentialFields[1][displayName]=Password
credentialFields[1][fieldType.typeName]=IF_PASSWORD
credentialFields[1][isEditable]=true
credentialFields[1][name]=PASSWORD
credentialFields[1][value]=testpass
credentialFields[1][valueIdentifier]=PASSWORD
credentialFields[1][valueMask]=LOGIN_FIELD
I've triple checked the parameters, and they seem to match up with the documentation.
Is there something I'm missing?
Looking at the documentation it looks like there's a mismatch in the format of your parameters.
For example, you have the field credentialFields[0][displayName], but in the documentation it's referred to as credentialFields[0].displayName. Is is possible that the API expects fields in this format?
If the API does expect fields in the credentialFields[0][displayName] then it would make sense for the credentialFields.enclosedType field to follow the same format. In that case it should be credentialFields[enclosedType].
I want to display the tweets of an account in my website. The problem is that the tweets appear always with the format http://t.co/..., instead of the full link as desired by me.
For instance, I obtain:
the rules of the game are all implemented - local players can play together in this link: http://t.co/Nf7j4TaB
if you are very curious... then, here is the link to the xodul's section under development: http://t.co/6Zbti36T
etc...
and I want that these tweets appear like this:
the rules of the game are all implemented - local players can play together in this link: http://xodul.com/tests/js/
if you are very curious... then, here is the link to the xodul's section under development: http://xodul.com/tests
etc...
To make my application I've followed the instructions from:
Simplest PHP example for retrieving user_timeline with Twitter API version 1.1 (from here we can get the text of each tweet, with the links coming in the format: http://t.co/...)
Rendering links in tweet when using Get Statuses API 1.1 (the code of the highest scored answer, in this link replaces, for instance, the text "http://t.co/Nf7j4TaB" with the hyperlink "<a target='_blank' href='http://t.co/Nf7j4TaB'>http://t.co/Nf7j4TaB</a>")
I appreciate very much any help on how to render the twitter's links!
With the tutorial you followed you can use these attributes to show actual link.
Note: In API v1.1, entities will always be included unless you set include_entities to False or 0.
The urls entity
An array of URLs extracted from the Tweet text. Each URL entity comes with the following attributes:
url: The URL that was extracted
display_url: (only for t.co links) Not a URL but a string to display instead of the URL
expanded_url: (only for t.co links) The fully resolved URL
indices: The character positions the URL was extracted from
https://dev.twitter.com/docs/tweet-entities
JavaScript only solution for now to get Twitter posts on your site without using new 1.1 API and actually returns the full url in posts, not the twitter shortened version :-) http://goo.gl/JinwJ
Thank you for your answers.
After analyzing the JSON in the suggested link (https://dev.twitter.com/docs/tweet-entities), I wrote a solution to the exposed problem:
// ...
$twitter_data = json_decode($json); // last line of the code in: http://stackoverflow.com/questions/12916539
// print the tweets, with the full URLs:
foreach ($twitter_data as $item) {
$text = $item->text;
foreach ($item->entities->urls as $url) {
$text = str_replace($url->url, $url->expanded_url, $text);
}
echo $text . '<br /><br />';
// optionally, here, the code from: http://stackoverflow.com/questions/15610968/
// can be added, too.
}
I am trying to develop a grails application that returns kml (to be viewed in Google Earth) using the controller code snippet below.
render(contentType: "application/vnd.google-earth.kml+xml",
view:"kml",
model:[feeds: feeds, feedColors: feedColors]);
This works great...but Google Earth does not open the response until it is first saved to disk and renamed with a '.kml' extension. This is very annoying and will greatly limit the use of my web application.
How do I add the .kml extension to the response name returned from grails render method?
I think this will work:
response.setHeader("Content-disposition", "attachment; filename=${filename}.kml");
render(contentType: "application/vnd.google-earth.kml+xml",
view:"kml",
model:[feeds: feeds, feedColors: feedColors]);