Publishing photo to Facebook via Graph API: OAuthException: (#100) param tags must be an array - arrays

I'm attempting to upload a photo to Facebook via the Graph API on a test user account for my app. With just the url, link, name parameters present, the upload works fine returning a valid photo id.
However, if I use the additional tags parameter, I end up with the following error returned:
{
"error": {
"message": "(#100) param tags must be an array.",
"type": "OAuthException",
"code": 100
}
}
I've tried to provide the value for tags in almost every possible way I can think of, as I know the Graph API isn't straightforward (even the parameter url which is used to upload a photo from a URL isn't listed under the photo Graph API method);
A single user id
tags=100003919104407
Multiple CS'd user ids
tags=100003919104407,100003919104408,100003919104409
Array with ids not as integers
tags=[100003919104407, 100003919104404,100003919104405]
Array with ids as strings
tags=["100003919104407", "100003919104404","100003919104405"]
Array containing objects, as per the Facebook Graph API documentation
tags=[{"id":"100003919104407"},{"id":"100003919104404"},{"id":"100003919104405"}]
If someone could tell me the right format/another parameter through which to pass user ids in order to have them tagged in a photo, I'd be very grateful.

Try this
It should be in this format
[{"to":"100003919104407","x":0,"y":0},
{"to":"100003919104408","x":10,"y":10},
{"to":"100003919104409","x":20,"y":20}]
or
[{"tag_uid":"100003919104407","x":0,"y":0},
{"tag_uid":"100003919104408","x":10,"y":10},
{"tag_uid":"100003919104409","x":20,"y":20}]

Where did you get your information from? Have you check the tags section?
Create
You can create a tag on the photo by issuing an HTTP POST request to
the tags connection, PHOTO_ID/tags.
Note: This feature is intended to help users tag their friends in real
photos. You should not use this feature to encourage users to tag
their friends if their friends are not actually in that photo, or to
tag friends in composite photos. If your app is found to be
encouraging this behavior, your usage of this feature may be disabled.
You can specify which user to tag using two methods: in the URL path
as PHOTO_ID/tags/USER_ID, or in a URL parameter as
PHOTO_ID/tags?to=USER_ID. To add several tags at once, you can specify
a tags property which contains an array of tags like so
PHOTO_ID/tags?tags=[{"id":"1234"}, {"id":"12345"}]. Currently, you
cannot tag a Page in a photo using this API.
There's also an example.

the X and Y value of array need to be %, not in pixels
Example 1 (wrong)
img:(640,480) xy:(320,240)
[{tag_uid:user_id,x:320,y:240}] <- wrong, because 320 > 100%
Example 2 (right)
img:(640,480) xy:(320,240) px:(320,240) < %
[{tag_uid:user_id,x:50,y:50}] <- right, because 50 < 100%

Related

Use query string in URL or use multiple URL?

If I want to display many posts in my web application but every post have its own type and I want to display each type in single page so, What's the best method to do that? Is put all all posts in one url and use query string to filter the posts upon the type and display it in the page?
For example : axios.get('/posts?type =sport')
Or I have to put every single type in separate Url
For example: axios.get('/posts/sport')
Also one more question please?
use one reducer to manage every posts or create one reducer for each post type?
you can add a dynamic route to every new type.
Ex:
'/transaction' -> component-1
'/transaction/:type' -> component-any (multiple)
welcome to Stackoverflow!
I can imagine you have a web API of some sort serving a URL /posts. You want to consume that endpoint from your web application, and you are using axios to do that. I can assume you are using JSON to return that data. Correct me if I'm wrong.
Now that the basic information is "clear", what data you serve from the endpoint, and how it is requested from the client is up to you. Do you want to ask the server what types are there first, and then do one AJAX request per type? Ok. Do you want to serve all posts independent of their type? Ok. Do you want to accept POST data in your controller so you can filter the results before returning a response? Ok.
If you are looking for a more specific answer, you must give more details, or specify more. But I hope I could be of help.
Edit: complete answer.
If you want to filter the results, you have to send some additional data in your POST request, in this case, your post type. In axios, this could be done like this:
axios.post('https://example.com/posts', {
type: 'sports'
}).then((data) => {
console.log(data);
});
You can obviously get the "type" value from a select input, other variable, even the current router page. I don't know your exact setup, but you can always come back and ask ;)
THEN, in your API controller you have to get that POST parameter type, and use it to filter the results. Again, I don't know your exact setup, but for MySQL if would be a WHERE statement in your query, or similar.

Swagger - Array of key-value pairs with unknown keys

I am trying to write a Swagger API document but I am having issues with one particular scenario.
I have a huge grid with id references in each (think Chess Board) and I want to send grid references that have changed and the new ID in each. So I may have a 40x40 grid and I change one of the grid squares to a different value.
I want to send to my API :
12x21 = 12345
23x11 = 87654
42x01 = 12987
23x09 = 19283
Without having to list every single grid position in swagger as a parameter, how can I represent this scenario using Swagger UI?
I would design one endpoint where you send the change to as a PUT request (or a POST request if it is a new id, it's hard to tell from the context), with the actual change as the JSON body of your request. The reference to your grid could then either be sent as query parameters or as part of the JSON body.

Redrawing endpoints using jsPlumb

I have been stuck with this a few days and want your help to know how to tackle this problem.
I created this application something like a flowchart to draw different types of plumb items with different endpoints attached to them. After it is being created as an element the endpoints are added dynamically according to the type of plumb item. is it like the following.
This is how I create the plumb items.
var element = document.createElement("div");
element.setAttribute("id",schema_id);
element.setAttribute("class","item " +control.Type);
element.setAttribute("style","left:" +posX + "px ; top: "+posY+"px");
var output = document.getElementById('container');
output.appendChild(element);
And then I add the endpoints according to its type.
jsPlumb.addEndpoint(element,<the style goes here>,{ anchor:<the location of the endpoint goes here>, uuid: <a new ID is created for this>});
And this is what it looks like
Screen One
I managed to grabbed the data from the method "GetConnections" and get it saved in the DB as a JSON. This JSON includes all the IDs which are for plumb items and all the endpoints.
But when I try to retrieve it back again to the UI, it appears like this. Everything appears great except the endpoints.
Screen Two
On redraw, the endpoints are created in the same way mentioned above. To reconnect the endpoints I am using this code.
jsPlumb.connect({ source:<source id>, target:<target id>,anchors:<location of the endpoint>,<style>);
The problem :
For the above code, Although I give the UUID of the endpoint to the source and target, it doesn't identify it as endpoints to connect from and to.
Is there a way to find the ID and get them connected? What I found out was that only the plumb items could be searched with "getElementById" with the UUID but not the endpoints.
The problem is how to make these endpoints get connected as originally drawn. How can connect each endpoint back again? I have all the IDs and when they are redrawn they are having the same IDs as it had when it was saved. But I couldn't find a way to connect the endpoints back again separately since this has different types of endpoints specific to each plumb item.
Any suggestions?
Sorry for the long post
Thank you in advance!!
Please see the connect method
If you connect ids, or elements, or Endpoints use
jsPlumb.connect({source:<source id>, target:<target id>});
but if you connect array of UUIDs of the two Endpoints use
jsPlumb.connect({uuids:<array of uuids>});

Manipulating Soundcloud Stream with Chrome Extension Content Script

I am writing a Chrome extension using AngularJS to add functionality to the Soundcloud stream page. I want to allow the user to create groups of artists so that they may only see a stream with tracks/shares/playlists from that group of artists.
For example, I follow 500 artists, but I want to quickly see a stream from my favorite 10 artists or from the artists I follow that are on the same label.
I am looking for advice on how I could go about making this as seamless as possible. As of right now, my approach involves getting the tracks with the Soundcloud API and using angular's ng-repeat to display the tracks in a view injected into where the stream normally goes. I realized using the Soundcloud widget was too slow and can't be customized to resemble the native stream items, so I copy/pasted the HTML that an actual stream item uses, but obviously the waveform/comment canvas and button functionality don't work.
What are my options as far as how I can approach this? Am I going to need to write my own players that look like the native Soundcloud ones? Any suggestions would be greatly appreciated.
You should use the SoundCloud API which is very well documented.
If you have already the id's of the tracks / artist, you just have to request the url
GET
http://api.soundcloud.com/tracks/ID_OF_TRACK.json?client_id=YOUR_CLIENT_ID
to get all the informations you need about this track, like the waveform_url, and for the comments you was talking about :
GET
http://api.soundcloud.com/tracks/ID_OF_TRACK/comments.json?client_id=YOUR_CLIENT_ID
To reproduce the behaviour of the comments :
POST http://api.soundcloud.com/tracks/ID_OF_TRACK/comments.json?client_id=YOUR_CLIENT_ID
(with a body param which represents the text and a timestamp in ms since the beginnin of the song, note that you must be connected)
If you don't have the id of the track, you could also use the resolve which give you all the info about a ressource if you have only the URL :
GET
http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/poldoore/pete-rock-c-l-smooth-they&client_id=YOUR_CLIENT_ID

relate an object in salesforce with multiple objects

1) I have created a custom object "Hello".
Added two lookup fields to it, one is associated to Accounts and another to Leads.
2) now my custom object appears as a related list in both Account and lead
3) if i goto an account say "**Test_account**" >> i click on the new button
on the "Hello" related list.here i have redirected to a custom
visualforce page "**Welcome**".
Now I want that on my "Welcome Page" I want to display 2 fields.
If user reached this "Welcome Page" via hello related list in accounts then label on this page is set to Accounts
but
If user reached this "Welcome Page" via hello related list in leads then label on this page is set to Leads.
I dont know how to do this.
I can get the retURL in the currentpage URL but it gives me only the id.
Now I am not sure this id belongs to Accounts or Leads.
Accounts nad leads are just examples,there could be many more ojects.
By looking at the first three characters of the id, you can tell the type of object. For example, all Accounts start with '001' and all Leads start with '00Q'. You can get all the key prefixes from the DescribeSObjectResult in either Apex or the Web Services API. The API also returns this in the DescribeGlobalResult, which is handy if you want to load all the key prefixes in one call. The REST API also has the key prefix, but you'd have to traverse all the objects to get to it.

Resources