Facebook Canvas:redirect_uri不归应用程序所有(Facebook Canvas: redirect_uri is not owned by the application)
我正在尝试将facebook canvas集成到当前在
localhost:8080
上运行的Web应用程序localhost:8080
运行该站点时它给了我这个错误。API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application.
这是我的应用程序设置。
我刚刚关注文档,这个错误出现了,
window.fbAsyncInit = function() { FB .init({ appId : 'myappIdHere', // App ID channelUrl : 'https://apps.facebook.com/mytestapp/', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); FB.ui({ method : 'feed' }); }; // Load the SDK Asynchronously (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));
I am trying to integrate facebook canvas on my web application that is currently running on
localhost:8080
upon running the site it gave me this error.API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application.
And here is my app settings.
I was just following the documentation and this error showed up,
window.fbAsyncInit = function() { FB .init({ appId : 'myappIdHere', // App ID channelUrl : 'https://apps.facebook.com/mytestapp/', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); FB.ui({ method : 'feed' }); }; // Load the SDK Asynchronously (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));
原文:
最满意答案
虽然我没有看到运行您发布的示例代码的任何问题,但如果您在应用程序中看不到一致的结果,那么创建自己的滚动控制器并不是太棘手。 这是您可以使用的示例实现:
private class ScrollPositioner { private static final int SCROLL_DURATION = 20; private static final int DIR_UP = 1; private static final int DIR_DOWN = 2; int mTargetPosition = AdapterView.INVALID_POSITION; int mDirection = AdapterView.INVALID_POSITION; int mLastSeenPosition = AdapterView.INVALID_POSITION; int mExtraScroll; GridView mGrid; public ScrollPositioner(GridView grid) { mGrid = grid; mExtraScroll = ViewConfiguration.get(mGrid.getContext()).getScaledFadingEdgeLength(); } Handler mHandler = new Handler(); Runnable mScroller = new Runnable() { public void run() { int firstPos = mGrid.getFirstVisiblePosition(); switch(mDirection) { case DIR_UP: { if (firstPos == mLastSeenPosition) { // No new views, let things keep going. mHandler.postDelayed(mScroller, SCROLL_DURATION); return; } final View firstView = mGrid.getChildAt(0); if (firstView == null) { return; } final int firstViewTop = firstView.getTop(); final int extraScroll = firstPos > 0 ? mExtraScroll : mGrid.getPaddingTop(); mGrid.smoothScrollBy(firstViewTop - extraScroll, SCROLL_DURATION); mLastSeenPosition = firstPos; if (firstPos > mTargetPosition) { mHandler.postDelayed(mScroller, SCROLL_DURATION); } break; } case DIR_DOWN: { final int lastViewIndex = mGrid.getChildCount() - 1; final int lastPos = firstPos + lastViewIndex; if (lastViewIndex < 0) { return; } if (lastPos == mLastSeenPosition) { // No new views, let things keep going. mHandler.postDelayed(mScroller, SCROLL_DURATION); return; } final View lastView = mGrid.getChildAt(lastViewIndex); final int lastViewHeight = lastView.getHeight(); final int lastViewTop = lastView.getTop(); final int lastViewPixelsShowing = mGrid.getHeight() - lastViewTop; final int extraScroll = lastPos < mGrid.getAdapter().getCount() - 1 ? mExtraScroll : mGrid.getPaddingBottom(); mGrid.smoothScrollBy(lastViewHeight - lastViewPixelsShowing + extraScroll, SCROLL_DURATION); mLastSeenPosition = lastPos; if (lastPos < mTargetPosition) { mHandler.postDelayed(mScroller, SCROLL_DURATION); } break; } default: break; } } }; public void scrollToPosition(int position) { mTargetPosition = position; mLastSeenPosition = AdapterView.INVALID_POSITION; if(position < mGrid.getFirstVisiblePosition()) { mDirection = DIR_UP; } else if (position > mGrid.getLastVisiblePosition()) { mDirection = DIR_DOWN; } else { return; } mHandler.post(mScroller); } }
这是您链接的示例的片段,其中包括此新类的位置,以代替框架实现进行滚动:
GridView g; boolean t= false; @Override public void onBackPressed() { //Instantiate and attach the custom positioner if(mPositioner == null) { mPositioner = new ScrollPositioner(g); } //Use the custom object to scroll the view mPositioner.scrollToPosition(0); if(t) { super.onBackPressed(); } else { t = true; } }
如果要添加一个功能,即使滚动方向向下,所选位置也始终滚动到顶部,您可以这样做。 这不是框架实现的目的 ,但您可以通过在
DIR_DOWN
添加一些代码来继续滚动直到第一个可见位置与目标匹配(如DIR_UP
)。 您还必须注意滚动在位置到达顶部之前结束的情况,因此在您永远不会得到不同结果的情况下,您不会经常发布处理程序。HTH
While I'm not seeing any issues running the example code you posted, if you're not seeing consistent results in your application it's not too tricky to create your own scroll controller. Here's an example implementation you could use:
private class ScrollPositioner { private static final int SCROLL_DURATION = 20; private static final int DIR_UP = 1; private static final int DIR_DOWN = 2; int mTargetPosition = AdapterView.INVALID_POSITION; int mDirection = AdapterView.INVALID_POSITION; int mLastSeenPosition = AdapterView.INVALID_POSITION; int mExtraScroll; GridView mGrid; public ScrollPositioner(GridView grid) { mGrid = grid; mExtraScroll = ViewConfiguration.get(mGrid.getContext()).getScaledFadingEdgeLength(); } Handler mHandler = new Handler(); Runnable mScroller = new Runnable() { public void run() { int firstPos = mGrid.getFirstVisiblePosition(); switch(mDirection) { case DIR_UP: { if (firstPos == mLastSeenPosition) { // No new views, let things keep going. mHandler.postDelayed(mScroller, SCROLL_DURATION); return; } final View firstView = mGrid.getChildAt(0); if (firstView == null) { return; } final int firstViewTop = firstView.getTop(); final int extraScroll = firstPos > 0 ? mExtraScroll : mGrid.getPaddingTop(); mGrid.smoothScrollBy(firstViewTop - extraScroll, SCROLL_DURATION); mLastSeenPosition = firstPos; if (firstPos > mTargetPosition) { mHandler.postDelayed(mScroller, SCROLL_DURATION); } break; } case DIR_DOWN: { final int lastViewIndex = mGrid.getChildCount() - 1; final int lastPos = firstPos + lastViewIndex; if (lastViewIndex < 0) { return; } if (lastPos == mLastSeenPosition) { // No new views, let things keep going. mHandler.postDelayed(mScroller, SCROLL_DURATION); return; } final View lastView = mGrid.getChildAt(lastViewIndex); final int lastViewHeight = lastView.getHeight(); final int lastViewTop = lastView.getTop(); final int lastViewPixelsShowing = mGrid.getHeight() - lastViewTop; final int extraScroll = lastPos < mGrid.getAdapter().getCount() - 1 ? mExtraScroll : mGrid.getPaddingBottom(); mGrid.smoothScrollBy(lastViewHeight - lastViewPixelsShowing + extraScroll, SCROLL_DURATION); mLastSeenPosition = lastPos; if (lastPos < mTargetPosition) { mHandler.postDelayed(mScroller, SCROLL_DURATION); } break; } default: break; } } }; public void scrollToPosition(int position) { mTargetPosition = position; mLastSeenPosition = AdapterView.INVALID_POSITION; if(position < mGrid.getFirstVisiblePosition()) { mDirection = DIR_UP; } else if (position > mGrid.getLastVisiblePosition()) { mDirection = DIR_DOWN; } else { return; } mHandler.post(mScroller); } }
Here's a snippet from the example you linked that includes where this new class to do the scrolling in place of the framework implementation:
GridView g; boolean t= false; @Override public void onBackPressed() { //Instantiate and attach the custom positioner if(mPositioner == null) { mPositioner = new ScrollPositioner(g); } //Use the custom object to scroll the view mPositioner.scrollToPosition(0); if(t) { super.onBackPressed(); } else { t = true; } }
If you want to add a feature where the selected position is always scrolled to the top even when the scrolling direction is down, you could do that. This is not something the framework's implementation is designed to do, but you could accomplish it by adding some code in
DIR_DOWN
to continue scrolling until the first visible position matches target (likeDIR_UP
does). You must also beware of the case where the scrolling ends before the position reaches the top, so you aren't constantly posting the handler in cases where you will never get a different result.HTH
相关问答
更多-
无尽的滚动gridview?(Endless scrolling gridview?)[2022-12-14]
我最近对一个需要网格视图的项目进行了研究。 这些是我发现的组件: https://github.com/AlanQuatermain/AQGridView - 我的个人喜好。 https://github.com/provideal/MMGridView https://github.com/danielctull/DTGridView 如果你决定自己创建一个,我会遵循一些组件的做法,并使用类似于UITableView的API。 I researched this quite recently for a ... -
尝试在GridView周围包装一个
-
使用此自定义面板解决了问题。 Problem solved using this custom panel.
-
总是尝试使用ViewHolder Pattern列表和网格来提高列表和网格的性能: @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; if(convertView==null){ viewHolder = new ViewHolder(); convertView = infla ...
-
首先,您必须添加scrollView作为父级,它将是片段和gridView的父级。 在那种情况下,基于gridview的滚动内容不是理想的解决方案,因为它将导致2滚动。 相反,您将不得不禁用gridview的滚动并向gridview添加高度。这将删除回收功能。 固定高度的GridView package com.mytestapp import android.util.AttributeSet; import android.view.ViewGroup; import android.widget.Gr ...
-
我想滚动整个屏幕不仅仅是Android中的GridView?(I want to scroll the whole screen not only the GridView in Android?)[2023-09-30]
由此覆盖您的GridView Touch,但请记住,此后您无法滚动您的gridview Yourgridview.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_MOVE){ return true; ... -
我可以使用RecyclerView垂直滚动并使用ViewPager同时水平滚动。 尝试实现viewPager以水平滚动。 The simplest solution is Use a horizontal scroll view to contain the GridView Then dynamically re-size the GridView width based on the number of columns that you set for the GridView Lastly, mult ...
-
GridView的平滑滚动(Smooth Scroll for GridView)[2023-10-07]
虽然我没有看到运行您发布的示例代码的任何问题,但如果您在应用程序中看不到一致的结果,那么创建自己的滚动控制器并不是太棘手。 这是您可以使用的示例实现: private class ScrollPositioner { private static final int SCROLL_DURATION = 20; private static final int DIR_UP = 1; private static final int DIR_DOWN = 2; int mTa ... -
你能提供你已经完成的代码(html和css)吗? 您可以在GridView周围放置一个周围的DIV。 下面的代码在您的gridview周围放置了一个DIV。 使用overflow(y显示垂直滚动条)和零填充的CSS(首选外部CSS文件)。 如果还有填充,那么页面上的CSS就会出现问题。