Trying to find a good javascript function for hmac-sha1 - html

So i have been searching the web for a javascript source for an Hmac-sha1 algorithm. I saw Crypto's but i cant seem to get it to work, mainly because it has no idea what crypto means. (i copied the .js script functions into my script file) http://code.google.com/p/crypto-js/ I have my base64 encoded function already. that i got from here:
http://nerds-central.blogspot.com/2007/01/fast-scalable-javascript-and-vbscript.html
btw this for a twitter application using the new OAuth system.
any help or links to where i can find anything on this would be helpful
If you need me to elaborate let me know. thank you!

I haven't tried it, but 'jssha' seems to have added HMAC support to its SHA-X library recently:
http://jssha.sourceforge.net/

Related

Wordpress JSON API returns normal site page in html. How do I get it to give me JSON like it's supposed to

For example, entering http://mywordpresswebsite.example.com/?json=1 into the browser loads the main site html, the same as omitting the json querystring variable: http://mywordpresswebsite.example.com/
The JSON API is activated. I have tried reactivating and deactivating, checking .htaccess file settings, and deactivating all other plugins. None of those have made much difference so far.
TIA
I had the same problem with my localhost test page and was wondering, why my route worked last week and was not accessible this week.
Short explanation
After some tests and a lot of frustration, I was able to use the REST API Route again by following the wordpress documentation about routes-vs-endpoints with “Pretty Permalinks” and “Ugly” Permalinks
Longer explanation
I guess in my case it was based on the reinstall of my MySQL Database. By installing the new database, my previous setup has been reset to the wordpress standard installation with permalinks as "plain", which is an "ugly" permalink. That's the reason, why the answer of Mattygabe work for me after the reinstall of the database.
But with this solution, I had a problem with my filter value and therefore I found the solution with "pretty premalinks" and changed my permalinks to "Month and name", as shown in the picture. After this change, I could access my REST API via the desired route.
There could be also some difficulties with REST APIs related to the following examples:
using "wp" within the REST route
if you work on plugins, which should be shared, keep on mind that some plugins may restrict REST Access, e.g. iThemes Security
I'm likely doing it wrong, but when I form my requests for a Wordpress installation at http://www.example.com/ like this:
http://www.example.com/index.php?rest_route=/my/rest/route/here
I end up getting proper responses back.
I had a heck of a time figuring this out and ended up grokking a URL formatted like that in the HTML returned to me. I was expecting to make requests as http://www.example.com/wp_json/wp/v2/my/rest/route/here , but I only got HTML responses.
(FWIW, I am reposting this on all similar questions on the StackExchange network. Admins/mods - if this is against the rules or seen as rep spamming, feel free to take it down. Was hoping to help anyone else hitting the same issue I am, and to also learn what it is I've done wrong and why.)
Ok, so the new endpoint for Wordpress 4.7 is mywordpresswebsite.example.com/index.php/wp-json. It's part of Wordpress Core as of 4.7 and not a plugin anymore, there's nothing to be activated. Thank you, Mark Kaplun.
I also experienced this issue. I did install the WP API plugin and then realized I didn't need it so I deactivated it and deleted it. Afterwards I tried a GET request to https://example.com/wp-json/wp/v2/posts and received the HTML of my wordpress site.
To fix this I ended up deactivating all plugins and then I started receiving the JSON response from https://example.com/wp-json/wp/v2/posts so I stepped through each plugin reactivating and in the end all my plugins are active and the endpoint is responding with JSON.
I changed Permalinks (Settings => Permalinks)
I had an issue returning html page instead of JSON response on Wordpress 5.3 and I got resolved when I changed the Permalink as Post name from plain

How do I parse a json image returned from an API?

To make an example Wordpress plugin that shows an image, or at least stores it in the media library, I go out to the NASA Open API and fetch the Astronomy Picture of the Day. I have not yet tested that code, but assuming it works my problem is: then what? I guess I have to parse the return data and somehow get an image file I can upload to the library. I'm used to grabbing pre-known text fields such as data.customerid, etc. but never an image. The API site is not much help. I have gleaned from around here a few references to "base64" but I don't know what that means. I can't find a straightup example if what to do. Any thoughts?
you'll have to do steps along this lines, you are pretty much correct on that:
fetch response from API (example: https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY)
parse url:
use media_sideload_image function in WordPress to save image in media to be able to show it in your plugin or to your users..
I suggest you to start building your plugin from scratch and then when you get stuck post your code here and community can help you better..

Getting queryString from GET request from website- alternative Tools then Selenium

Aim:
I´m testing a specific site and I want to check wheater the sent key-value-pairs are valid.
I need to get the queryString parameters (key-value-pairs) of a GET request on a website. The queryString is only accessible via the GET requests and is NOT in the url. (I want to compare these key-value-pairs from the website later with other key-value-pairs from a file/html/..etc.)
This is what I did and know until now:
I know I can visualize the K/V-pairs when using FireBug->Network->Parameters.
I can get a GET request with the Selenium WebDriver, but it is complicated to extract the queryString out of the JSON-Object. [I was using Java with jsoup and json.simple]
The only tool I know which can compare key-values on a website is Columbo.io, but I have to write the compared values manually into the tool- that is not flexible enough for my purpose.
In my research I found the following tools: PhantomJS, Ranorex, SmartBear TestComplete, Wetator, Sahi Pro, RedGlass, TestingBot, BugBuster, Canoo Webtest. I sadly cannot find out if these tools are able to give me the key-value-pairs I desire.
Problem:
With Selenium I expect to need a lot of time for writing tests, like maybe 2-4 weeks? So I am searching for other tools which can extract the key-value-pairs of a website easier or quicker.
Question:
Which tools can you recommend for getting these parameters easily?
And if there isn´t any better tool then Selenium then please tell me: maybe I´m overlooking some other issue and there are i.e. better API´s for parsing the JSON-Object to get the key-value-pairs or other things I could improve?
Are there any sites where I can read the experiences of other persons with specific tools.
PS: This is my first question here on Stackoverflow. I hope you can understand and help me.
I am not sure if I get your point correctly but if you want to play with HTTP requests and key-value-pairs, you may have a try to perform with Apache HttpClient which can be integrated with your Selenium-Webdriver java. Hope it can help.

JSON to blueprint/MSON

I havent been able to find any tools for this conversion, does anyone know of any that exist.
Currently, I have JSON data from Swagger that I would like to convert to Blueprint/MSON to use with Apiary, but I am not sure if this is possible. Any recommendations would be super helpful, or suggestions for other routes to try and onboard my API to Apiary without manually writing it.
There is one here: MSONGenerator. Takes a while to load, but you paste your JSON and get nice MSON out of it. No source code for it as far as I can see, but I didn't look very far.
There's also mson-to-schemas, an npm package. I have no experience with it.
Source: API Blueprint tools section

Chrome Extension Internals

I am trying to understand the internals of Chrome Extension. It will be great if you can provide more details regarding this.
My understandings are as follows:
Extensions run in its own process.
Extensions interact with Browser process through IPC.
My question:
1. Whenever we call a extension api such as chrome.module.function() from extension user script, I would expect the function to go to the renderer process first and then send a IPC such as ExtensionHostMsg_ABC to the browser process to do the required operation.
Extension Process Browser Process
ExtensionHostMsg_Req
chrome.module.function() ----------------> Handle the msg
ExtensionMsg_Response
Send the result back to js <-----------------
But to my surprise, I see that all the extension api functions are declared and defined in chrome/browser/extensions/xyz_api.h & .cc files. So it looks like when a api is called from js, we come directly to the browser process. Where and how does this magic happens?
I also see some extensions bindings c++ code in chrome/renderer/extensions/abc_bindings.cc and the corresponding js code in chrome/renderer/extensions/resources/abc.js. I think we have this code to share some information between the extension renderer and js code. Is it right? Can you provide me a example scenario for this?
Sorry for asking these basic questions. I really appreciate your help.
Regarding your question on how the bindings are made. You define your extension API in chrome/common/extensions/api/extension_api.json which is how V8 sets up the C++ JavaScript bindings. That is where all the magic happens :)
If you want to call privileged APIs from the content script you would need to add the namespace to chrome/renderer/resources/extensions/renderer_extension_bindings.js
For more information regarding the design of the Extension System in Chromium, there are good docs that explain the whole process model and interactions:
http://www.chromium.org/developers/design-documents/extensions